Skip to content

Instantly share code, notes, and snippets.

@jeena
Forked from ttepasse/gist:4100377
Created November 17, 2012 21:18
Show Gist options
  • Save jeena/4100386 to your computer and use it in GitHub Desktop.
Save jeena/4100386 to your computer and use it in GitHub Desktop.
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