I'm trying to create a helper function that will return 0 if an element in a nested array is undefined. The issue I'm facing is that when the first index fails and returns undefined, the function should catch errors at subsequent indexes but it's not reaching them. What is the best approach to handle all errors in this situation?
function errorCatcher(arr){
if (typeof(arr) == 'undefined') {
return 0
}
var some_var = errorCatcher(some_arr[0][1]) // even though some_arr[0] causes an error here, I want the helper function to catch all errors