I found this in a piece of code and i’m wondering what it does? Assign b to x… but what’s with the ,c?
var x = b, c;
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.
That declares two variables,
xandc, and assigns valuebto variablex.This is equivalent to the more explicit form*:
JavaScript allows multiple declarations per
varkeyword – each new variable is separated by a comma. This is the style suggested by JSLint, which instructs developers to use a single var per function (the error message from JSLint isCombine this with the previous 'var' statement.).* Actually, due to hoisting it will be interpreted as
var x; var c; x = b.