Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Created May 9, 2014 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikari-no-yume/b06da1119526f499141b to your computer and use it in GitHub Desktop.
Save hikari-no-yume/b06da1119526f499141b to your computer and use it in GitHub Desktop.
How to mess with JavaScript programmers
var TotallyNotArray = Object.create(Array.prototype);
TotallyNotArray.constructor = Array;
var EvilArray = function () {
return Object.create(TotallyNotArray);
};
// Now do x = EvilArray(); in Chrome's dev console
// It'll show up like an array, and all operations will work...
// But there's no magic .length property! >:D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment