Check if object member exists in nested object

后端 未结 8 1003
花落未央
花落未央 2020-11-27 05:00

Is there a simpler way than using ___ in object to check the existence of each level of an object to check the existence of a single member?

More conci

8条回答
  •  囚心锁ツ
    2020-11-27 05:27

    Theres a safeRead function defined here on thecodeabode which allows a safeRead of nested properties i.e.

    safeRead(foo, 'bar', 'jim', 'jam');
    

    if any of the properties are null or undefined a blank string is returned - useful for formatting / string interpolation

提交回复
热议问题