About the strange features in JS

var a = {
    value:2,
    toString:function()
    {
        console.log("........");
        return PPthis.value;
    }
}

if(a==3 && a==4){
    console.log("JS is amazing");
}

as above, using toString will output "JS is amazing". If I try to replace it, such as toLocaleString, it won"t be output. what feature of JS makes this?

Mar.04,2021

when using = instead of identity, implicit conversion will be triggered if the original value is not equal, that is, an implicit conversion will be triggered by calling the toString method of the left value to convert it into a string, so it cannot be achieved when you replace toString with toLocaleString .


when judging, the toString method will be called if it is repeated in the object. Replace it with toLocaleString and it will find the toString method on the prototype

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