-
Notifications
You must be signed in to change notification settings - Fork 1
Function_evisit_core_js_data_toLookup
Wyatt Greenway edited this page Jan 31, 2017
·
1 revision
- key
- (String) Key to match on all objects. If key is undefined or null, the index will be used instead.
- data
- (Array) Array to create map from
- (Object) Each key in the object will be the value in the Array specified by 'key'
This takes an Array and returns a reference map for quick lookup.
var myMap = toLookup('id', [ { id:'derp', field: 'derp' }, { id:'dog', field: 'dog' }, { id:'cat', field: 'cat' } ]); myMap === { 'derp': { id:'derp', field: 'derp' }, 'dog': { id:'dog', field: 'dog' }, 'cat': { id:'cat', field: 'cat' } };