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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
void function() { //closure | |
var global = this | |
, _initKeyboardEvent_type = (function( e ) { | |
try { | |
e.initKeyboardEvent( | |
"keyup" // in DOMString typeArg | |
, false // in boolean canBubbleArg | |
, false // in boolean cancelableArg | |
, global // in views::AbstractView viewArg |
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
// Reduce collection using provided conditions | |
// e.g. FriendList.where({age: 30, gender: 'male'}) | |
// Returns object of the same "class", so it's possible to chain methods | |
Backbone.Collection.prototype.where = function(conditions) { | |
return new this.constructor(_(conditions).reduce(function(memo, value, key) { | |
memo = _(memo).filter(function(model) { | |
return model.get(key) === value; | |
}); | |
return memo; | |
}, this.models)); |