Resolves a value as per resolve, however f an error is thrown or the resolution results in undefined or NaN, the fallback value is returned instead.
null is an allowed return value.
null
// Function returns undefined 50% of the time or 0const fn = () => { if (Math.random() >= 0.5) return; // undefined return 0;}const r = resolveWithFallback(fn, 1);const value = r(); // Always 0 or 1 Copy
// Function returns undefined 50% of the time or 0const fn = () => { if (Math.random() >= 0.5) return; // undefined return 0;}const r = resolveWithFallback(fn, 1);const value = r(); // Always 0 or 1
See also resolveWithFallbackSync
Thing to resolve
Fallback value if an error happens, undefined or NaN
Resolves a value as per resolve, however f an error is thrown or the resolution results in undefined or NaN, the fallback value is returned instead.
null
is an allowed return value.See also resolveWithFallbackSync