dimanche 2 février 2020

In Javscript why does an object value that targets a non-declared variable return "result"?

jsfiddle

in the following, the variable name was never declared. The value is returned as the string "result". Isn't this incorrect, shouldn't it be "undefined"?


let obj = {
name: name,
age: "23"
}

alert(obj.name);

or

obj = {
name,
age: "23"
}

alert(obj.name);



Aucun commentaire:

Enregistrer un commentaire