Sort of:
var key = "myKey"; myArray.push( { key : value} ); I know that you can:
var key = "myKey"; var obj = {}; obj[key] = value; myArray.push(obj); But it does not fit, since it is for me when I create the object I need to refer to the key.
Sort of:
var key = "myKey"; myArray.push( { key : value} ); I know that you can:
var key = "myKey"; var obj = {}; obj[key] = value; myArray.push(obj); But it does not fit, since it is for me when I create the object I need to refer to the key.
Source: https://ru.stackoverflow.com/questions/553134/
All Articles