prop-by-string
Introduction:
Get and set an object property by string. Supports nested array notation.
.get(propString, object)
Get an object property by string literal.
Any erroneous request will return undefined
.
Arguments
propString
- A string specification of what you want to fetch.object
- The object you want to fetch from.
Example
var propByString = ; var myObject = myList: myNestedList: name: 'Eirik' age: 28 ; var result = propByString;// Eirik var result = propByString;// undefined
.set(propString, update, object)
Mutate an object by specifying the location as a string literal.
Arguments
propString
- A string specification of what you want to fetch.update
- The update you want to insert (any primitive / object).object
- The object you want to mutate.
The method returns the mutated object as a convenience.
Example
var propByString = ; var original = a: b: c: d: 'hello' var mutated = propByString;// {// a: {// b: {// c: {// d: [['hello', 'world']]// }// }// }// }