Skip to content

Instantly share code, notes, and snippets.

@himynameisdave
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save himynameisdave/5a9925b76048217466c9 to your computer and use it in GitHub Desktop.

Select an option

Save himynameisdave/5a9925b76048217466c9 to your computer and use it in GitHub Desktop.
.bind() For Dummies [WORKS FINE BUT NOT IDEAL]
// [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