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
| /** | |
| * Removes all falsy and undefined values from an object | |
| * @param {object} o Object to be compacted | |
| * @return {object} Compact Object | |
| * @link http://stackoverflow.com/a/14058408/417822 | |
| */ | |
| _.mixin({'compactObject': function(o) { | |
| var clone = _.clone(o); | |
| _.each(clone, function(v, k) { |
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
| Collection1 = Backbone.Collection.extend({ | |
| initialize: function(models, options){ | |
| // bad, causes things to crash if options.that doesn’t get passed. | |
| this.doSomethingWithThat(options.that); | |
| } | |
| }); | |
| // Crashes since 'that' is not set | |
| collection1 = new Collection1(); |
NewerOlder