0

I wanted to change this code which is using get method from lodash library to optional chaining method.Can someone help me to convert this

return get(
          this.UIObj,
          'excelList',
          []
        );

1 Answers1

0

Optional return the excelList property of this.UIObj, and if it's undefined (or null) return an empty array using the Nullish coalescing operator (??):

return this.UIObj?.excelList ?? []
Ori Drori
  • 183,571
  • 29
  • 224
  • 209