JavaScript implicit type conversion steps and javascript steps
Here, implicit type conversion is a conversion caused by =.
- If NaN exists, false is returned.
- If there is a Boolean, the Boolean is converted to a number.
- Check whether there are any strings. In three cases, the opposite party is an object and the object is converted using toString. The other party is a number and the string is converted to a number. The other party is a string and can be directly compared. Otherwise, false is returned.
- If it is a number, the other party is an object, and the object is compared with valueOf, all others will return false
- Null, undefined does not perform type conversion, but they are equal
This order must be memorized, which is frequently asked during interviews.
The following are some miscellaneous questions.
0 = undefined1 = true2 = {valueOf: function () {return 2} NaN = NaN 8 = undefined1 = undefined null = {toString: function () {return 2} 0 = null = 1 {toString: function () {return 1}, valueOf: function () {return [] }== 1
Summary
The above section describes the JavaScript implicit type conversion procedure. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!