Home >Web Front-end >JS Tutorial >javascript short circuit method code streamlining_javascript skills
I encountered a piece of code as follows
if(n>win) {
p=dArry.length-win;
}
else if(np=0;
}
else {
p=n;
}
There are many similar codes. Let’s continue to simplify. It’s actually very simple. It becomes like this
p=((n>win)&&( dArry.length-win))||((nTo summarize: && takes the last value, || takes the first satisfying value, efficient, but please use it flexibly