Home > Web Front-end > JS Tutorial > javascript short circuit method code streamlining_javascript skills

javascript short circuit method code streamlining_javascript skills

WBOY
Release: 2016-05-16 18:47:58
Original
942 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template