node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

inner

Inner

Get and set values in deeply nested objects.

Installation

npm install inner

Usage

var inner = require('inner');
var object = {
  user: {
    name: 'John',
    friends: ['Mike', 'Alex']
  }
};
 
inner.get(object, ['user', 'friends', '0']); // -> 'Mike' 
inner.set(object, ['user', 'name'], 'Chris'); // object.user.name == 'Chris' 
inner.has(object, ['user', 'friends', '1']); // -> true 

Credits

Inner is just like this library, but with support for specifying nested properties as arrays instead of strings.