I have a simple code like this:
var name = 'line1';
var obj = {};
obj.name = [0, 1];
console.log(obj);
Key of property is name. But I want to make key='line'. Can you help me?
Try,
obj[name]
or
obj["line1"]
This is known as the bracket notation, and can be used to access any property of an object.