javascript - What does "this._events || (this._events = {});" mean? -
 I have started learning backbone.js. Currently my javascript skills are not very good. I have started checking the   line     This is a trick that Javascript uses "false" evaluation: this is the same:    goes to the same line  var events = this._events [name] || (This._events [name] = []);  can be translated into   backbone.js  file and I've got a strange line code whose purpose I can not understand. Code sample (if you need more context, manually download for developers and see line 80):   
 var Events = Backbone.Events = {// callback to an event callback 'Tie in function. The "all" passes will have callback / bind to close all events. On: Function (Name, Callback, Context) {If (! Event API (this, 'on', name, [callback, reference]) .backback); This._events || (This._events = {}); Var events = this._events [name] || (This._events [name] = []); Events.push ({callback: callback, context: context, CTX: context || this}); Back it; },    this._events || (This._events = {});  mean? For me,  _events  looks like an internal variable, but used for  (this._events = {})  assignment, or it's a  or < / strong> is a comparison? Or  =  Is there a completely different process in this context?    
 if (this._events) {// nothing is, this._ events are already defined} other {this._events = {}; }    
 var events; If (this._ events [name]) {events = this._events [name]; } Other {these._events [name] = []; Events = this._events [name]; }    
 
  
Comments
Post a Comment