Yeah, it works in my firebug console. Why does something like this present no syntax error?
[] = 5; [] = doThis(); [] = (function() {})();
Just curious about why it’s allowed.
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.
Looks like Javascript in FF allows assignment using matching so you can set multiple variables in one shot:
“Obviously”, some JS implementations are very forgiving, and will silently ignore any extra values, so this does the same:
and this would just not assign anything:
and on top of that, it looks like FF is even willing to go with a case that doesn’t match an array at all:
so if you use
[] = whateverthen “nothing gets assigned an undefined value”, so it boils down to just evaluating the RHS.(Disclaimer: this is all just guessing the meaning by running stuff in FF…)