I have been looking through new wordpress theme twentyfourteen and notice the following line in their javascript file:
var nav = $( '#primary-navigation' ), button, menu;
Can somebody explain me what does it mean, it does not look like a multiple variable assignment in a single line. Also button and menu are not defined yet, so how come it does not produce an error?
You are just declaring three variables and assigning value to only nav. Both button and menu will have undefined, by default.
var a = 1, b, c;
console.log(a, b, c);
Output
1 undefined undefined
Instead, if you see something like this
var d = (1, 2, 3);
console.log(d);
Output
3
The expressions within the brackets will be evaluated from left to right and the result of the last evaluation will be assigned to d.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With