I often read through source code as a good resource for learning programming. I was looking at Backbone.Model's fetch()
method and had this question I was hoping someone could shed some light on.
Here is the fetch() method:
// ---------------------------------------------------------------------
// Fetch the model from the server. If the server's representation of the
// model differs from its current attributes, they will be overriden,
// triggering a `"change"` event.
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 if (options.parse === void 0)...
? void 0
simply evaluates to 'undefined', so is this a shorthand for testing if the property is not defined? And if so, does it have any advantages over the standard (typeof options.parse === 'undefined')
statement, which I find more semantic and readable?