Home > front end >  If statements to optimize
If statements to optimize

Time:01-05

Consult everybody, how such an if nested optimization??
 
If (this. EditedIndex===1) {
Enclosing isParentNode=true;
Enclosing the editable=false;
} else {
If (item. Pid===0) {
Enclosing isParentNode=true;
} else {
Enclosing isParentNode=false;
Enclosing the editable=false;
}
}

CodePudding user response:

Enclosing isParentNode=this. EditedIndex===1 | | item. The pid===0? true : false;
Enclosing the editable=this. EditedIndex===1 | | item. The pid!==0? False: enclosing the editable.

CodePudding user response:

IsParentNode=(enclosing editedIndex!=1 & amp; & The item pid!=0)? False: true

CodePudding user response:

reference 3 floor however response:
isParentNode=(enclosing editedIndex!=1 & amp; & The item pid!=0)? False: true
simplify can't have lost the variable assignment to ah...

CodePudding user response:

reference 3 floor however response:
isParentNode=(enclosing editedIndex!=1 & amp; & The item pid!=0)? False: true

Indeed, fewer enclosing the editable variables,
  • Related