I create a Object like below,
var s = {
`1234`:`string`
}
But, It will throw the below Error,
Uncaught SyntaxError: Unexpected template string
How Can I create Such Elements?
I create a Object like below,
var s = {
`1234`:`string`
}
But, It will throw the below Error,
Uncaught SyntaxError: Unexpected template string
How Can I create Such Elements?
You could use computed property names with brackets, because the template literal returns a string, which works like a variable.
var object = { [`1234`]:`string` };
console.log(object);
You should be using quotes instead of backticks, try this:
var s = { '123': 'string'}