diff --git a/README.md b/README.md index 0618ca9fa..9a156d0f7 100644 --- a/README.md +++ b/README.md @@ -3904,7 +3904,7 @@ Use a `try... catch` block to return either the result of the function or an app ```js const attempt = (fn, ...args) => { try { - return fn(args); + return fn(...args); } catch (e) { return e instanceof Error ? e : new Error(e); } diff --git a/docs/index.html b/docs/index.html index 948e1eb10..1078621c4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -888,7 +888,7 @@ recorder.sta tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)

Function

attempt

Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.

Use a try... catch block to return either the result of the function or an appropriate error.

const attempt = (fn, ...args) => {
   try {
-    return fn(args);
+    return fn(...args);
   } catch (e) {
     return e instanceof Error ? e : new Error(e);
   }