-
Create a function called
safeCall
that accepts another functionf
as a parameter, callsf
without any arguments and returnstrue
iff
has executed without any errors orfalse
iff
has thrown an error. Sample usage:safeCall(() => console.log('Hello!')); // true safeCall(() => JSON.parse('abc')); // false safeCall(() => false); // true safeCall(() => abc); // false
-
(optional) Make
safeCall
callable on any function:f.safeCall(...)
. It should take the same parameters and has the same effect asf.call(...)
, except in case whenf
throws an error, it should instead just returnnull
without throwing any errors.
shurkodr / js_safe-call Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mate-academy/js_safe-call