Created
October 5, 2014 19:25
-
-
Save vlyahovich/e259d87234a6dfa90b7f to your computer and use it in GitHub Desktop.
Fast and slow objects example
This file contains 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 FastPurchase (units, price) { | |
this.units = units; | |
this.price = price; | |
this.total = 0; | |
this.x = 1; | |
}; | |
var fast = new FastPurchase(3, 25); | |
fast.x = null; | |
function SlowPurchase (units, price) { | |
this.units = units; | |
this.price = price; | |
this.total = 0; | |
this.x = 1; | |
}; | |
var slow = new SlowPurchase(3, 25); | |
delete slow.x; | |
// Up to 3 times more memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment