Skip to content

Instantly share code, notes, and snippets.

@iampava
Last active August 2, 2017 16:39
Show Gist options
  • Save iampava/1c4da7e80ab3dcb1280b5cef8a6ca828 to your computer and use it in GitHub Desktop.
Save iampava/1c4da7e80ab3dcb1280b5cef8a6ca828 to your computer and use it in GitHub Desktop.
Hacking Javascript |
var money;
sharedPiggyBank.store('push', function(value) {
// YES, we can add properties to arrays!
this[this.length] = value;
money = this;
});
sharedPiggyBank.push('$22'); // resolves to the push method we added and not to Array.prototype.push
sharedPiggyBank.push('$33'); // money = ['$22', '$33'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment