fork download
  1. var $ = obj => new Proxy({}, { get: (_, key) => key=='$' ? obj : $((obj||{})[key]) })
  2.  
  3.  
  4. var hoge = { fuga: { piyo: 'boo', puyo: 123 } }
  5.  
  6. var $hoge = $(hoge)
  7.  
  8.  
  9. x = $hoge.fuga.piyo.$ // 'boo'
  10. x = $hoge.fuga2.payo.$ // undefined
  11.  
  12. x = $hoge.fuga.puyo.$ // 123
  13. x = $hoge.fuga2.poyo.$ // undefined
  14.  
  15. if (hoge && hoge.fuga && hoge.fuga.puyo === 123) {}
  16. //↓
  17. if ($hoge.fuga.puyo.$ === 123) {}
  18.  
  19. if (hoge && hoge.fuga && hoge.fuga.piyo && hoge.fuga.piyo.length > 2) {}
  20. //↓
  21. if ($hoge.fuga.piyo.length.$ > 2) {}
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty