I want to ask about the NodeJS object(JSON), let see the case.
const myname = Date.now();
const scheme = {
custom_name: value, //the case
};
from the example above, what I want is the custom_name using the value of myname, is that possible?
I want to ask about the NodeJS object(JSON), let see the case.
const myname = Date.now();
const scheme = {
custom_name: value, //the case
};
from the example above, what I want is the custom_name using the value of myname, is that possible?
Sure it is, just use square bracket notation.
Of course, with date the toString representation will be used for the key:
const myname = Date.now();
const value = "foo"
const scheme = {
[myname]: value, //the case
};
console.log(scheme)