+ 2
Why is this showing I am not defined ?
const obj1 = {name: kashyap}; const obj2 = {age: 120}; const tar = Object.assign({}, obj1, obj2); console.log(tar); // kashyap is not defined
2 odpowiedzi
+ 5
{name: "kashyap"}
You need those quotes, otherwise it will search for a variable with the same name
+ 3
It should be a String.
const obj1 = {name: 'kashyap'};