i started thinking this, couldn't differences expose whilst mucking around in jsfiddle.
var = new array(1), b = array(1); console.log(a, b); output 2 arrays 1 undefined member.
doing for ( in ) reveals have same properties.
what differences between these? first 1 instantiate object explicitly?
please don't lecture me using array literal notation know that. i'm more wishing fill gap in knowledge explained above.
with array, both equivalent. new injected when it's called function:
15.4.1
arrayconstructor called functionwhen
arraycalled function rather constructor, creates , initialises new array object. function callarray(…)equivalent object creation expressionnew array(…)same arguments.
from ecma-262, 3th edition (with similar in 5th edition).
Comments
Post a Comment