当前位置:网站首页>在js中,0表示false,非0表示true
在js中,0表示false,非0表示true
2022-07-29 07:38:00 【杉菜酱_】
在弱类型语言js中,0表示false,非零表示true。
写项目过程中,在递归获取文件节点的完整路径时,遇到这个问题,记录一下,代码如下:
getName(params,name){
if(params && params != null){
if(params.id == 0){
// if(params.id && params.id == 0)前面的params.id为0时,整个表达式为false,程序不会进入此代码块中,因此不会return。
return name;
}
if(params.name){
name = params.name + '/' + name
}
return this.getName(params.parent,name)
}
},
if(params.id && params.id == 0)前面的params.id为0时,整个表达式为false,程序不会进入此代码块中,因此不会return,因此需要去掉params.id。
边栏推荐
- Thinkphp6 realizes database backup
- Cfdiv1+2-bash and a high math puzzle- (gcd+ summary of segment tree single point interval maintenance)
- Log4qt memory leak, use of heob memory detection tool
- 207. Curriculum
- Better performance and simpler lazy loading of intersectionobserverentry (observer)
- 【暑期每日一题】洛谷 P7760 [COCI2016-2017#5] Tuna
- Popular cow G
- do end用法的妙处
- 08 dynamic programming
- The difference between static library and dynamic library of program
猜你喜欢

RoBERTa:A Robustly Optimized BERT Pretraining Approach

Can the subset of the array accumulate K

LANDSCAPE

How does MySQL convert rows to columns?

Thinkphp6 realizes database backup

STM32 operation w25q256 w25q16 SPI flash

How can electronic component trading enterprises solve warehouse management problems with ERP system?
![[summer daily question] Luogu p7760 [coci2016-2017 5] tuna](/img/9a/f857538c574fb54bc1accb737d7aec.png)
[summer daily question] Luogu p7760 [coci2016-2017 5] tuna

I, 28, a tester, was ruthlessly dismissed in October: I want to remind people who are still learning to test

多线程购物
随机推荐
[summer daily question] Luogu p6461 [coci2006-2007 5] trik
[summer daily question] Luogu P6500 [coci2010-2011 3] zbroj
Matlab simulation of LDPC minimum sum decoding based on high-order six ring free
你学习·我奖励,21天学习挑战赛 | 等你来战
Log4qt memory leak, use of heob memory detection tool
Levelfilter introduction
Analyze the roadmap of 25 major DFI protocols and predict the seven major trends in the future of DFI
Prometheus and grafana
do end用法的妙处
Introduction and introduction of logback
监听页面滚动位置定位底部按钮(包含页面初始化定位不对鼠标滑动生效的解决方案)
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
10 practical uses of NFT
Prometheus与Grafana
【暑期每日一题】洛谷 P4413 [COCI2006-2007#2] R2
Sort out the two NFT pricing paradigms and four solutions on the market
Dilworth theorem
Dilworth 定理
QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
@Detailed explanation of requestmapping usage