I often read source code as a good resource for learning programming. I looked at the Backbone.Model method fetch()and had this question, I was hoping that someone could shed some light.
Here is the fetch () method:
fetch: function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) options.parse = true;
var success = options.success;
options.success = function(model, resp, options) {
if (!model.set(model.parse(resp, options), options)) return false;
if (success) success(model, resp, options);
};
return this.sync('read', this, options);
}
My question is: what is the point of the if condition ? just evaluates to 'undefined', so is it a shortcut for testing if the property is not defined? And if so, does it have any advantages over the standard operator , which I find more semantic and readable? if (options.parse === void 0)... void 0 (typeof options.parse === 'undefined')
source
share