Referring to the model.set() function in backbone.js: Is there a way to supply the key value as a variable rather than having it hard-coded?
In my code below, setting the key as the variable prop literally sets the name of the key as “prop” whereas I need the name of the key to actually be the value stored in the variable prop.
var filters = new Filters();
for (var pair in facetsCollection) {
for (var prop in facetsCollection[pair]) {
filters.set({prop: (facetsCollection[pair])[prop]);
}
}
you can do it easily like this: