source:
node_modules/undefsafe/example.js
| Last change on this file was 81bc7da, checked in by , 3 months ago | |
|---|---|
|
|
| File size: 245 bytes | |
| Rev | Line | |
|---|---|---|
| [81bc7da] | 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.
