The output of the variable is very strange.

topic description

the output of the object is not the expected result

sources of topics and their own ideas

in daily programming

related codes

        var obj = {"a" : 1};
        var obj1 = {"b" : obj};
        console.log(obj1);
        console.log(obj);
        obj.a = 3;

what result do you expect? What is the error message actually seen?

expected result: {b: {aburel}}. The actual output is shown in figure

.
Jul.23,2021

if you output like this, the result will be as expected:

var obj = {"a" : 1};
var obj1 = {"b" : obj};
console.log(JSON.stringify(obj1));
console.log(JSON.stringify(obj));
obj.a = 3;

this is because methods such as console.log/dir/. display the latest state of the object in memory when it is output, so the value of a in your output has been modified to the latest value (that is, affected by obj.a = 3 ).

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