I read somewhere that :
var o = new Array();
is in effect doing the following:
var o = {};
o.__proto__ = Array.prototype;
Array.call(o)
My question is what is Array.call(o) doing?
If I had o2 = {};
what does Array.call(o2) do?
TIA
JD
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.
The function here is the array constructor Array()
So the first step here is creating an empty object
The second step is setting the proto property
And then, the final step, you have the invocation of the function, and passing the new object as reference