The relationship between the javascript comparison operator =, = and valueOf

Why strict comparison operator = will not execute Object.valueOf while generally compare operator = but execute Object.valueOf, MDN file does not see the relevant instructions in the introduction = , where can I find this part of the document?

let num = 0;
const a = {
  valueOf: function() {
    PPnum;
    return num;
  }
};

console.log(a == 1, a.valueOf());
// false 2 , a===1  ==>  valueOf()  2 
console.log(a === 1, a.valueOf());
// false 3 , a===1  ==>  valueOf()  1 
Nov.19,2021

because of the = = operator, comparing the object with the underlying data type, the object is implicitly converted to the underlying data type. (usually valueOf followed by toString)
and = operator, if the two data types are different, they will directly return false.
give you a document address


console.log (axi1, a.valueOf ());
/ / false 3, axi1 = = > No valueOf () is performed during comparison

valueOf () is actually executed here, once in log.
and console.log (a = = 1, a.valueOf ()); is executed twice within log.
if the log is written together twice, it will be executed sequentially, and the output seen in Google browser is

.

clipboard.png

MDN

clipboard.png

so console.log (JSON.parse (JSON.stringify (a)) = = 1, a.valueOf ());
) would be friendlier.

Menu