javascript tricks. Why (a,b,c) => 5

javascript

Solution

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).

Problem

. ``` 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 ?

Original source