Js interview questions, seek analysis. The more detailed the better.

for parsing, a.b and a [b] are both written to get object properties. But the difference is that the b of a [b] can only be a string.
how does the following code parse, and why is the output value 345345333?

var a = {};
var b = {key: "b"};
var c = {key: "c"};
var d = [3Yue5Yue6];
a [b] = 123;
a [c] = 345;
a [d] = 333;
console.log (a [b]);
console.log (a [c]);
console.log (a [d]);


The key value of

object is a string, b and c are both the same object. If you take them as the key value of a, you will first convert them into a string. After the object is converted into a string, it is [object Object] , so a [b] = 123 is a [[object Object]'] = 123, and execute a [c] = 345. The a [[object Object]'] will be re-assigned to 345, so printing a [c] and a [d] is the value of a [[object Object]'], and the result is 345

. When

array d is converted into a string, the result is 3 code 5 code >, so a [d] = 333; that is, a ['3jue 5je 6'] = 333 *. The same way to take the value is to take the value

of a ['3jue 5jue 6']. < H2 > add < / H2 >

Symbol types available as object properties in es6


Object built-in toString and valueOf methods;
in this case a [b] = 123 will call the object's toString ().
a [b] = 123, that is, a [[object Object]'] = 123
a [c] will lead to toString () and a [[object Object]'] = 345;
and the array toStirng () ='[object Array]';
the final a should be {'[object Object]': 345 object Array'[object Array]
what happens when ps: calls toString () by default? I'll check it first.
is wrong. It should be a {'[object Object]': 345, 5, 5, 5, 6, 3, 3, 3, 3, 3, 3, 3, 5, 5, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3 The key of

JS ordinary object can only be a string. If you want to use a variable as a key, you can use Map

.
  

the previous boss is right

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