当前位置:网站首页>JS variable is equal to 0, etc. '
JS variable is equal to 0, etc. '
2022-07-28 06:40:00 【Yandun】
var a = 0;
if(a==""){
a = 2;
}
The final result of this line of code ,a by 2; because :a==0==""==false;
stay js in 0、false、"" Is the default value of equality ;
Such as int The default value is 0,bool The default value is false, The default value of the string is "" namely :
0==false==""
1==true="1"
As a weakly typed language, it must be compatible with the definitions of various types , Generally, these three types are used ;
So to solve this problem , You can judge first isNaN, In judging typeOf type , Do the conversion again parseInt... Mode switching ;
边栏推荐
猜你喜欢

气传导蓝牙耳机哪个好、气传导蓝牙耳机排行榜

2022-06-07 responsebodyadvice caused the spring frame problem in swagger

Icc2 (IV) routing and postroute optimization

SSAO By Computer Shader(二)

七夕送什么礼物最实用?送人绝对不会出错的礼物值得买
![[队列,栈的简单应用----包装机]](/img/bc/617b1eb35558c4f948018f593a1de5.jpg)
[队列,栈的简单应用----包装机]

2022-06-07 六.日志实现

Leetcode brush question diary sword finger offer II 053. Medium order successor in binary search tree

什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐

用c语言实现三子棋小游戏
随机推荐
[PTA--利用队列解决猴子选大王问题】
Leetcode brush question diary sword finger offer II 048. serialization and deserialization binary tree
【动态规划--买卖股票的最佳时期系列2】
刷题记录----二叉树
OJ 1131 beautiful number
【C笔记】数据类型及存储
OJ 1451 digital games
Bug experience related to IAP jump of stm32
OJ 1284 counting problem
MFC uses the console to print program information
七夕送什么礼物最实用?送人绝对不会出错的礼物值得买
OJ 1129 分数矩阵
图形管线基础(二)
2022-05-15 based on JWT token
OJ 1131 美丽数
1、 Ffmpeg record audio as PCM file
[C note] data type and storage
Icc2 (IV) routing and postroute optimization
【C语言】字符串库函数介绍及模拟
RayMarching实现体积光渲染