source:
node_modules/undefsafe/example.js@
2d1ec46
| Last change on this file since 2d1ec46 was 81bc7da, checked in by , 3 months ago | |
|---|---|
|
|
| File size: 245 bytes | |
| Line | |
|---|---|
| 1 | var undefsafe = require('undefsafe'); |
| 2 | |
| 3 | var object = { |
| 4 | a: { |
| 5 | b: { |
| 6 | c: 1, |
| 7 | d: [1, 2, 3], |
| 8 | e: 'remy' |
| 9 | } |
| 10 | } |
| 11 | }; |
| 12 | |
| 13 | console.log(undefsafe(object, 'a.b.e')); // "remy" |
| 14 | console.log(undefsafe(object, 'a.b.not.found')); // undefined |
Note:
See TracBrowser
for help on using the repository browser.
