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'
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
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 => {