Can I add a key-value pair to an object and have the key be equal to a variable?

  • Thread starter Francis TF Queen
  • Start date
F

Francis TF Queen

Guest
I want to add a key-value pair to an object, but i want the key to be equal to a variable. Here's what I mean:

var variable;

Object.assign(myObject, {variable: value})


Is there any way to do this?

Continue reading...
 
Top