example.js 245 B

123456789101112131415
  1. var undefsafe = require('undefsafe');
  2. var object = {
  3. a: {
  4. b: {
  5. c: 1,
  6. d: [1, 2, 3],
  7. e: 'remy'
  8. }
  9. }
  10. };
  11. console.log(undefsafe(object, 'a.b.e')); // "remy"
  12. console.log(undefsafe(object, 'a.b.not.found')); // undefined