Is there a shorthand way to create an object with a property field variable?
Say I have the variable PROP.Todo.PRIORITY = 'priority'
and then, using Backbone in this example, I want to save this property, how can I avoid having to create a new object, assigning it to some variable and then set the property?
I want to achieve this:
var tmpObj = {};
tmpObj[PROP.Todo.PRIORITY] = "high";
this.model.save(tmpObj);
I've tried something like this, which was unsuccessful:
this.model.save(({}[PROP.Todo.PRIORITY] = "high"));
Any suggestions? I'm going to be writing a lot of long-hand object declarations otherwise.