Strange javascript syntax -


anybody can me following js syntax? don't understand line starting "( $.inarray( wzdid, this...." mean why line start parentesis? mean?

this complete code:

_activatestep: function( wzdid ) {   if ( condition ) {     var stepindex = this._findnav( wzdid ).index();      for( var = 0; < stepindex; ++i) {        if( condition ) === -1 ) {         return;       }     }     ( $.inarray( wzdid, this._activatedsteps ) === -1 ) && this._activatedsteps.push( wzdid );   } } 

thank you

what have here is

a && b 

it uses common trick based on short-circuit logical operators : b executed if true.

that's way write

if (a) b; 

some people because it's little shorter. it's less readable too.


Comments

Popular posts from this blog

asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -

kineticjs - draw multiple lines and delete individual line -

thumbnails - jQuery image rotate on hover -