Js object > = comparison is a strange phenomenon of true, ask for guidance, why, is there any relevant specification?

Why do two objects compare > =, < = will be true?

a = {a:1};
b = {b:1};
console.log("a == b : ", a==b);   // a == b :  false
console.log("a > b : ", a>b);     // a > b :  false
console.log("a < b : ", a<b);     // a < b :  false
console.log("a >= b : ", a>=b);   // a >= b :  true
console.log("a <= b : ", a<=b);   // a <= b :  true
Aug.04,2021

clipboard.png


https://tc39.github.io/ecma26...


Javascript

:github

:

  1. '<''>'string
  2. '<''>'number
  3. 12ToPrimitivestringToNumbernumber

:



javascript=====(> , < , >=, <=)

a >= ba <= btrueaba == bfalse>=(>,<,<=)==== false

javascript:
valueOf;valueOftoString


but it doesn't seem quite right to me, because the object's valueOf method returns the object itself valueOf__MDN , so I think it's a called toString method, so it translates to" [object Object] "> =" [object Object] "and" [object Object] "< =" [object Object] ". So it's all true

. The result of

Number ({}) is that NaN
NaN is another special constant that is not equal to itself


the comparison operator
refers to the data type and converts it to the base data type, first valueOf and then toString. Get: "[object Object]" > = "[object Object]" . If both strings are exactly the same, then true is returned.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46494-4cf3e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46494-4cf3e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?