Hello everyone. I am relatively new to js and I have this bit of code I am trying to understand.
1) Why is the first line var for test_obj curly braces instead of brackets?
2) Why does the second line exist at all? Didn't we already declare it in line one? Why is it ".number"?
2) Why does line three follow with .number.number, and again, why isn't declaring this value on line one suffice?
Thanks for your help!
let test_obj = {};
test_obj.number = {};
test_obj.number.number = 8;
let new_number = test_obj.number;
new_number.number = new_number.number + 5;
console.log(test_obj.number.number);
1) Why is the first line var for test_obj curly braces instead of brackets?
2) Why does the second line exist at all? Didn't we already declare it in line one? Why is it ".number"?
2) Why does line three follow with .number.number, and again, why isn't declaring this value on line one suffice?
Thanks for your help!
let test_obj = {};
test_obj.number = {};
test_obj.number.number = 8;
let new_number = test_obj.number;
new_number.number = new_number.number + 5;
console.log(test_obj.number.number);
Last edited: