== About JavaScript in the! Conversion issues

Recently met a very interesting JavaScript questions, feel very interesting. Record it so after the interview experience

Entitled:

console.log([]==![],{}==!{},[]==!{},{}==![])

This question is examined primarily == number of implicit conversion,

In all there are objects without data are true, so when console.log({}==!{})the equivalent of true == time! True so the result is false.

When it is determined by double equal sign [] == [] is a conversion algorithm according ToNumber, empty array [] ToNumber conversion algorithm to 0 is false, and! ToBoolean operator is used to convert the algorithm should be empty array it is an object [] converted to! true, so console.log([]==[])when the equivalent false == false, so the result is true.

By the same token Finally console.log({} == []), should be the object Under no circumstances are true, and [] uses algorithms to convert ToBoolean, equivalent! True, so the result is equivalent to true ==! True result is false.

Guess you like

Origin www.cnblogs.com/yuanchao-blog/p/11448107.html