Skip to content

Instantly share code, notes, and snippets.

@colinbate
Created March 13, 2014 17:32
Show Gist options
  • Save colinbate/9533031 to your computer and use it in GitHub Desktop.
Save colinbate/9533031 to your computer and use it in GitHub Desktop.
Create a map from an array of similar objects
function createKeyedArray (keyName, arr) {
var ii, obj = {};
for (ii = 0; ii < arr.length; ii += 1) {
obj[arr[ii][keyName]] = arr[ii];
}
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment