Get a property from a model or object. For the reverse, checkout ianstormtaylor/set
.
$ component install ianstormtaylor/get
Plain objects:
var get = require('get');
var person = { name: 'ulysses' };
get(person, 'name'); // ulysses
Getter/setter methods:
var get = require('get')
, model = require('model');
var Person = model('person').attr('name');
var person = new Person({ name: 'ulysses' });
get(person, 'name'); // ulysses
Get methods:
var Backbone = require('backbone')
, get = require('get');
var person = new Backbone.Model({ name: 'ulysses' });
get(person, 'name')); // ulysses
Get the given prop
from model
.
MIT