+ 1
A question
Array.prototype.func = () => return (this instance of Array); alert((new Array()).func()); Why the output is false? Does the __proto__ of new object not point to prototype of Array? I have also tried to use "this.constructor==Array". But it doesn't work too. Does the constructor of prototype not point to Array class?
3 odpowiedzi
+ 3
just ditch the arrow function and go back to the regular function:
Array.prototype.func = function() { return (this instanceof Array); };
alert((new Array()).func());
more about arrow func:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
+ 2
this points to the global object in arrow function.
+ 1
An arrow functions doesn't have it's own this, thus rendering it not viable to be a method. In your code, this points to the Window object, which is not an instance of Array.
Make a function declaration like the other languages.