Javascript is a must-learn technology for web front-end development. What I will share with you today is the basic knowledge of implicit conversion of javascript. I hope it can help everyone learn better.
Convert to Boolean type false
undefined->falSe
null->falSe
numeric type 0 or 0.0 or NaN->falSe
String length is 0-> falSe
Other objects->true
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Convert to numerical data
undefined->NaN
null->0
true->1|falSe->0
The content is a number->Number, otherwise it is converted to NaN
Other objects->NaN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Converted to string data
undefined->"undefined"
null->"NaN"
true->"true" falSe->"falSe"
Numeric type->NaN, 0 or a string corresponding to a numerical value
Other objects->If this object exists, it is converted to the toString() method The value of