the following expression returns “e”
alert(["a","b","c","d","e"][[1,2],3,4]);
can anybody tell me why? thanks!
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.
All you need to do is break down the expression:
You are using bracket notation to access a property on the array literal. The syntax requires an expression. The syntax of an expression allows a single expression to contain many expressions when separated by a comma. Each term of the expression is evaluated left to right and the final value is actually the value of the last term. So your example can be replaced with this: