Skip to content

Instantly share code, notes, and snippets.

@arafeek
Created July 31, 2015 03:41
Show Gist options
  • Save arafeek/856c2f12d24e84fe4f22 to your computer and use it in GitHub Desktop.
Save arafeek/856c2f12d24e84fe4f22 to your computer and use it in GitHub Desktop.
Walk a complex object via a path string and mutate a variable
function set(obj, property, value) {
var properties = R.split('.',property);
var context = obj;
var i;
for(i=0; i < properties.length -1; i++) {
context = context[properties[i]];
}
context[properties[i]] = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment