Skip to content

Instantly share code, notes, and snippets.

@cristiandouce
Created April 15, 2013 21:58
Show Gist options
  • Save cristiandouce/5391608 to your computer and use it in GitHub Desktop.
Save cristiandouce/5391608 to your computer and use it in GitHub Desktop.
Option.prototype.getOption = function(setting) {
var ref = this;
setting = setting.split('.');
while (setting.length) {
if(!(ref = ref[setting.shift()])) break;
}
return ref;
}
@cristiandouce
Copy link
Author

works with something like this

> a
{ table: { rows: 1 }, get: [Function] }
> a.get('table')
{ rows: 1 }
> a.get('table.rows')
1
> a.get('table.rows.asdasdasd')
undefined
> a.get('asdf')
undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment