.
var a,b,c = function() { return 5; };
Variables a and b is undefined, c is function, why when we do this (a,b,c)() we have 5 ?
.
var a,b,c = function() { return 5; };
Variables a and b is undefined, c is function, why when we do this (a,b,c)() we have 5 ?
Because (a,b,c) evaluates to c.
See the comma operator. Works the same way in C, C++.
The declaration is the same as:
var a;
var b;
var c = function() { return 5; };
or practically the same as:
var a;
var b;
function c() { return 5; };
Using (a,b,c) has nothing to do with the declaration, it simply returns the last operand, so (a,b,c)() is exactly the same as c() (as long as evaluating a and b doesn't have any side effects).