When parsing my array, everything works fine if it is defined:
JSON.parse(myArray);
However, I encounter an exception if myArray is undefined.
What would be the best solution for this? Is there a more efficient alternative to this:
JSON.parse(myArray || '[]');
It's like verifying the object first to prevent exceptions if it's undefined
if (obj) {
//do something with obj.something
}
So, is there a more concise way than
JSON.parse(myArray || '[]');
Thank you.