The instanceof of js and the problem of wrapper object, come in and have a look.

clipboard.png
Why is this result? what is the difference between the directly declared string and new"s? why is the string of s new checked with instanceof, that is, Object and String?

Apr.09,2021

what's the difference between a directly declared string and a new

one is a literal string
one is an instance of String type, and valueOf returns a literal string, so 'a'! = = new String ('a') , but 'a' = = new String ('a') , 'a' = new String ('a'). ValueOf ()

Why is the string of s new checked with instanceof , that is, Object and String ?

because String inherits from Object , String instanceof Object


remember the JS prototype chain mechanism? The string that comes out through new String inherits the String object, and String inherits the Object object, so the following s instance Object | String is true. There are two data types: value type and reference type in
JS. S created by literals is directly assigned to the value 'hello', so it belongs to the value type.' hello' is an ordinary constant that does not inherit from any object, so s instance Object is false.
note that among the underlying types, only number boolean string can be passed by value, var obj = {}; is still a reference type.

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