62

JS 常用技巧

 5 years ago
source link: https://juejin.im/post/5c611c73f265da2d8f47159b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1. 类型强制转换1.1 string强制转换为数字可以用*1来转化为数字(实际上是调用.valueOf方法) 然后使用Number.isNaN来判断是否为NaN,或者使用 a !== a 来判断是否为NaN,因为 NaN !== NaN'32' * 1

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK