During the interview, I was asked such a question: "1" = 1, what are the rules for data type conversion, and how to judge?

the question "1" = = 1 is asked during the interview, and this judgment condition will convert "1" to number type 1 when executed, but how to verify it? (do I want to pass code verification? Because I don"t know how to verify it, I game over). Once again, my IQ has been crushed.

if it is an object and {} = = 1, the object is converted to the original value, which can be verified by the valueOf method that defines the object,

{valueOf:()=>{console.log("test")}} ==1;

but as mentioned in the title, how do you verify that a string is converted to a number?

Mar.16,2022

either the string from 1 to "1" or the number from "1" to 1

verify "1.00000" = = 1


Number.prototype.toString = function (v) {
  console.log('number');
  return v;
}

String.prototype.valueOf = function (v) {
  console.log('string');
  return '1';
}

1, object and undefined are compared by pointer
2, other types and numbers can be compared like this:'1' = = 1 = > Number ('1') = Number (1)

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-1e3c3b5-43edd.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-1e3c3b5-43edd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?