diff --git a/README.md b/README.md index 736b7ff6b..2ee4f93dc 100644 --- a/README.md +++ b/README.md @@ -4677,7 +4677,7 @@ const getType = v => Examples ```js -getType(new Set([1, 2, 3])); // 'Set' +getType(new Set([1, 2, 3])); // 'set' ``` diff --git a/docs/index.html b/docs/index.html index 99584e5dd..c10837337 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1035,7 +1035,7 @@ console.log< words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"]

Type

getType

Returns the native type of a value.

Returns lowercased constructor name of value, "undefined" or "null" if value is undefined or null.

const getType = v =>
   v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
-
getType(new Set([1, 2, 3])); // 'Set'
+
getType(new Set([1, 2, 3])); // 'set'
 

isArray

Checks if the given argument is an array.

Use Array.isArray() to check if a value is classified as an array.

const isArray = val => Array.isArray(val);
 
isArray([1]); // true
 

isArrayLike

Checks if the provided argument is array-like (i.e. is iterable).

Use the spread operator (...) to check if the provided argument is iterable inside a try... catch block and the comma operator (,) to return the appropriate value.

const isArrayLike = val => {