javascript cannot read property 'find' of undefined code example
Example: Uncaught (in promise) TypeError: Cannot read property 'find' of undefined how to fix
Using ES6 arrow functions, you can call that helper function with a one-line callback (or more accurately, a closure) function that just returns the property you want. function getSafe(fn) { try { return fn(); } catch (e) { return undefined; } } // use it like this getSafe(() => obj. a. lot