Answer the question
In order to leave comments, you need to log in
Why is the order in which the object key is output in this way?
I'm learning JavaScript and there's an example in the book.
function f(o) {
o.message = "Изменено в f";
o = {
message: "Новый объект!"
};
console.log (`Внутри f: o.message="${o.message}" (после присваивания)`);
}
let o = {
message: 'Начальное значение'
};
console.log(`Перед вызовом f: o.message="${o.message}"`);
f(o);
console.log(`После вызова f: o.message="${o.message}"`);
o.message = "Изменено в f";
Answer the question
In order to leave comments, you need to log in
Because in the function f you have assigned a new object to the local variable (argument) o :
{
message: "Новый объект!"
}
Read what console.log does. And for one thing, how assignment works
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question