4

Please look at this code, I wanna know why the $ and {} was added to the alert method to pop up the key and value of user.

what is their functionality there?

let user = {
name: "John",
age: 30
};

// loop over keys-and-values
for (let [key, value] of Object.entries(user)) {
alert(`${key}:${value}`); // name:John, then age:30
}

Comments
Add Comment