Last active
August 2, 2017 16:39
-
-
Save iampava/1c4da7e80ab3dcb1280b5cef8a6ca828 to your computer and use it in GitHub Desktop.
Hacking Javascript |
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
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