Implicit type conversion is the conversion caused by ==. Let me share with you the JavaScript implicit type conversion steps through this article. Friends who are interested can take a look.
The implicit type conversion mentioned here, It is the conversion caused by ==.
If NaN exists, always return false
Check again to see if there is a Boolean, if there is a Boolean, convert the Boolean into a number
Then check to see if there is a string. There are three situations. The other 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 compared directly; otherwise, false is returned
If it is a number and the other party is an object, the object will be compared with valueOf, otherwise it will return false
null, undefined will not perform type conversion, but They are both equal
This order must be memorized by rote. This is often asked during interviews.
The following are some miscellaneous questions, you can do it yourself
0 == undefined 1 == true 2 == {valueOf: function(){return 2}} NaN == NaN 8 == undefined 1 == undefined null == {toString: function(){return 2}} 0 == null null == 1 { toString:function(){ return 1 } , valueOf:function(){ return [] }} == 1
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Postman simulates the method of sending a request with token
A brief discussion on Postman’s solution to the problem of passing token parameters
postman json springmvc test batch add instance
The above is the detailed content of A brief analysis of JavaScript implicit type conversion steps. For more information, please follow other related articles on the PHP Chinese website!