-
-
Save jeena/4100386 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyArray () { | |
console.log("bla"); | |
Array.call(this); | |
} | |
MyArray.prototype = Object.create(Array.prototype) | |
var x = new MyArray() | |
x.push("lala") | |
x.push("lolo") | |
x.indexOf("lolo") // -> 1 | |
x instanceof Array // -> true | |
Array.call(x); // würde auch gehen aber da wäre es vielleicht zu spät je nachdem was man da initialisiert hätte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment