lang
getType
getType(value)
Return the type of value
.
Since
0.14.0
Arguments
value (any)
Return
(string)
Example
getType(undefined)
// => 'Undefined'
getType(null)
// => 'Null'
getType(1)
// => 'Number'
getType(true)
// => 'Boolean'
getType('')
// => 'String'
getType(Symbol('foo'))
// => 'Symbol'
getType(0n)
// => 'BigInt'
getType({})
// => 'Object'
getType([])
// => 'Array'
getType(/\s/)
// => 'RegExp'
getType(new Date())
// => 'Date'
getType(function () {})
// => 'Function'
isArray
isArray(value)
Check if a value is an Array.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isArray([])
// => true
isBigInt
isBigInt(value)
Check if a value is a BigInt value.
Since
0.8.0
Arguments
value (any)
Return
(boolean)
Example
isBigInt(BigInt(1));
// => true
isBoolean
isBoolean(value)
Check if a value is a Boolean.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isBoolean(true);
// => true
isDate
isDate(value)
Check if a value is a Date object.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isDate([]);
// => true
isError
isError(value)
Check if a value is an Error object.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isError(new Error('error message'));
// => true
isFunction
isFunction(value)
Check if a value is a function, including generator function and async function.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isFunction(function () {});
// => true
isFunction(function* () {});
// => true
isNil
isNil(value)
Check if a value is null
or undefined
.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isNil(null);
// => true
isNil(undefined);
// => true
isNull
isNull(value)
Check if a value is null
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isNull(null);
// => true
isNumber
isNumber(value)
Check if a value is a Number.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isNumber(1);
// => true
isObject
isObject(value)
Check if a value is an Object.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isObject({});
// => true
isObject(null);
// => false
isRegExp
isRegExp(value)
Check if a value is a RegExp object.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isRegExp(/\s+/);
// => true
isString
isString(value)
Check if a value is a String.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isString('hello world');
// => true
isSymbol
isSymbol(value)
Check if a value is a Symbol value.
Since
0.8.0
Arguments
value (any)
Return
(boolean)
Example
isSymbol(Symbol('foo'));
// => true
isUndefined
isUndefined(value)
Check if a value is undefined
.
Since
0.1.0
Arguments
value (any)
Return
(boolean)
Example
isUndefined(void 0);
// => true