Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created August 20, 2014 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcromartie/0ecd2f22b5400b56db67 to your computer and use it in GitHub Desktop.
Save jcromartie/0ecd2f22b5400b56db67 to your computer and use it in GitHub Desktop.
function arrayAssocIn(obj, keys, val) {
var m = obj;
for (var ii = 0; ii < keys.length - 1; ii++) {
var k = keys[ii];
m = m[k] = m[k] || [];
}
m[keys[keys.length - 1]] = val;
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment