Consider this code:
var age = 3; console.log(\"I\'m \" + age + \" years old!\");
Are there any other ways to insert the value of a variabl
Since ES6, if you want to do string interpolation in object keys, you will get a SyntaxError: expected property name, got '${' if you do something like:
SyntaxError: expected property name, got '${'
let age = 3 let obj = { `${age}`: 3 }
You should do the following instead:
let obj = { [`${age}`]: 3 }