I'm an intermediate level javascript developer, trying to understand how a great javascript developer writes his code, and I decided to start looking for the Backbone library as a starting point.
here is a code snippet for initial setup in the spine, please help me figure this out.
code1 -
(function(){ var root = this; }).call(this);
is there any specific reason to use the call method simply with (), or is it just a coding preference, if I have to write the same code, I would do something like this.
(function(root){ })(this);
code2 -
var Backbone; if (typeof exports !== 'undefined') { Backbone = exports; } else { Backbone = root.Backbone = {}; }
now there is no definition of export in the global scope or not defined anywhere in the local scope, what is it if the block does here, if I wrote the same code, I would write
var Backbone = root.Backbone = {};
code 3
var _ = root._; if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;
again I cannot find a definition of need anywhere in a local or global area
nitesh sharma
source share