I use this syntax often but I don’t understand why it simply works.
var a = 1, b = a + 1;
console.log(b); // 2
In the event you’re declaring a var, after splitting them on a comma, the b already sees a as evaluated? Why is that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It has been defined as such.
First, the definition of the essential terms:
and:
The actual definition which applies to your question is this one:
So at the time #2 is executed, #1 has been evaluated already and you can use any effect of it in #2.