What does this mean in var definition:
var array = array || [];
… and next two parts of javascript are equal each other?
var array = array || [];
array.push([1],[2]);
array.push([3]);
=
var array = array.push([1],[2],[3]) || [];
?
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 means that if array is a falsy value (
undefined,nulletc.) – the value that will be assigned to thevar arrayis an empty array –[];EDIT:
the second part of your question – no these are not equivalent.
For instance, when array is
undefined:this will throw an exception.
This:
will not.