79440643

Date: 2025-02-14 22:18:29
Score: 1
Natty:
Report link

If I need to create an array from JSON.parse() and I don't know if the argument passed is undefined, I do something like this:

const myArray = JSON.parse(localStorage.getItem('items')) || [];
Reasons:
  • Blacklisted phrase (0.5): I need
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Stalkov