diff --git a/README.md b/README.md index 86a3c5f3f..8736dbb53 100644 --- a/README.md +++ b/README.md @@ -8838,14 +8838,14 @@ isUndefined(undefined); // true ### isValidJSON -Checks if the provided argument is a valid JSON. +Checks if the provided string is a valid JSON. -Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON. +Use `JSON.parse()` and a `try... catch` block to check if the provided string is a valid JSON. ```js -const isValidJSON = obj => { +const isValidJSON = str => { try { - JSON.parse(obj); + JSON.parse(str); return true; } catch (e) { return false; diff --git a/docs/type.html b/docs/type.html index 860d585fa..4eebeee49 100644 --- a/docs/type.html +++ b/docs/type.html @@ -176,9 +176,9 @@
isSymbol(Symbol('x')); // true
Returns true if the specified value is undefined, false otherwise.
Use the strict equality operator to check if the value and of val are equal to undefined.
const isUndefined = val => val === undefined;
isUndefined(undefined); // true -
Checks if the provided argument is a valid JSON.
Use JSON.parse() and a try... catch block to check if the provided argument is a valid JSON.
const isValidJSON = obj => { +
Checks if the provided string is a valid JSON.
Use JSON.parse() and a try... catch block to check if the provided string is a valid JSON.
const isValidJSON = str => { try { - JSON.parse(obj); + JSON.parse(str); return true; } catch (e) { return false; diff --git a/test/_30s.js b/test/_30s.js index 51766a58f..29773325a 100644 --- a/test/_30s.js +++ b/test/_30s.js @@ -613,9 +613,9 @@ const isSymbol = val => typeof val === 'symbol'; const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; const isUndefined = val => val === undefined; const isUpperCase = str => str === str.toUpperCase(); -const isValidJSON = obj => { +const isValidJSON = str => { try { - JSON.parse(obj); + JSON.parse(str); return true; } catch (e) { return false;