Last active
August 29, 2015 14:27
-
-
Save himynameisdave/5a9925b76048217466c9 to your computer and use it in GitHub Desktop.
.bind() For Dummies [WORKS FINE BUT NOT IDEAL]
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
| // [WORKS FINE BUT NOT IDEAL] | |
| addNewFlavor: function( ){ | |
| var safeToAdd = true, | |
| context = this; | |
| // check if we've added it already | |
| this.flavors.forEach(function(flavor){ | |
| if(flavor === context.newFlavor) | |
| safeToAdd = false; | |
| }); | |
| if(safeToAdd) | |
| this.flavors.push(this.newFlavor); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment