Doubt in Javascript objects

Asked

Viewed 19 times

0

When creating a constant and then adding it as a property within an object, the object understands that it is from it (i.e., that it is the same thing), but at that moment I will have the const name and the aluno1.name (two different variables). How does this work underneath? I can’t understand this logic...


const aluno1 = {
  nome,
};

console.log(nome); // Pedro
console.log(aluno1.nome); // Pedro

aluno1.nome = "José";

console.log(nome); // Pedro
console.log(aluno1.nome); // José
  • the name is variable?

  • It is a constant but could be a tb Let

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.