任何人都可以帮助我使用以下Js语法? 我不明白以“($ .inArray(wzdId,this ......”)开头的行。 我的意思是为什么这条线开始只是一个肠胃外给药? 这是什么意思?
这是完整的代码:
_activateStep: function( wzdId ) {
if ( condition ) {
var stepIndex = this._findNav( wzdId ).index();
for( var i = 0; i < stepIndex; ++i) {
if( condition ) === -1 ) {
return;
}
}
( $.inArray( wzdId, this._activatedSteps ) === -1 ) && this._activatedSteps.push( wzdId );
}
}
谢谢
答案 0 :(得分:6)
你在这里有什么
A && B
它使用基于短路logical operators的常见技巧:仅当A为真时才执行B.
这是另一种写作方式
if (A) B;
有些人喜欢它,因为它有点短。它的可读性显然要低得多。