What Is The Difference Between Array.function And Array.prototype.function?
I've found that some functions like concat() push() every() both exist in Array and Array.prototype(with firefox 57.0.1 console) It's confusing since prototype methods exist in Arr
Solution 1:
Firefox's Array
function appears to have additional (non-conformant) "static" methods that replicate the prototype methods except that they take the array as the first parameter instead of via the implicit this
context.
To see those methods and properties of Array
, use:
Object.getOwnPropertyNames(Array)
In Firefox you'll (mostly) see the same list as in your first screenshot. I haven't yet figured out why Array.isArray
is missing in your list, but it does appear in my Firefox 57.
In Chrome you'll only see the ES6 mandated "static" methods (i.e. Array.from
, Array.isArray
, Array.of
) and the standard properties.
Post a Comment for "What Is The Difference Between Array.function And Array.prototype.function?"