utilities

Methods

(static) isArray(x) → {boolean}

Source:

Determines whether a value is an array.

This function merely delegates to Array.isArray. It is provided for consistency in calling style only.

Parameters:
Name Type Description
x *

The value being tested to see if it is an array.

Returns:

Either true if the test value is an array or false if it is not.

Type
boolean

(static) isFunction(x) → {boolean}

Source:

Determines whether a value is a function.

Parameters:
Name Type Description
x *

The value being tested to see if it is a function.

Returns:

Either true if the test value is a function or false if it is not.

Type
boolean

(static) isGeneratorFunction(`x`) → {boolean}

Source:

Determines whether a value is a generator function.

This function will return false either for regular (non-generator) functions (functions that are not defined with function*) or for generators themselves (the objects that are returned when you invoke a generator function).

Parameters:
Name Type Description
`x` *

The value being tested to see if it is a generator function

Returns:

Either true if the test value is a generator function or false if it is not.

Type
boolean

(static) isNumber(x) → {boolean}

Source:

Determines whether the value is a number.

This merely delegates to Number.isFinite, which both checks to see that a value is actually a number (and not merely convertible to one, the way global isFinite does) and that it is not Infinity or NaN.

Note that while this will return true for numbers created using Number(x), it will return false for objects created with new Number(x). The latter are not considered numbers, and typeof will return "object" for them rather than "number".

Parameters:
Name Type Description
x *

The value being tested to see if it's a number.

Returns:

Either true if the value is a number or false if it is not.

Type
boolean

(static) isObject(x) → {boolean}

Source:

Determines whether a value is a plain object.

This function returns false if the value is any other sort of built-in object (such as an array or a string). It also returns false for any object that is created by a constructor that is not Object's constructor, meaning that "instances" of custom "classes" will return false. Therefore it's only going to return true for literal objects or those created with Object.create().

Parameters:
Name Type Description
x *

The value being tested to see if it is a plain object.

Returns:

Either true if the value is a plain object or false if it is not.

Type
boolean

(static) isString(x) → {boolean}

Source:

Determines whether a value is a string.

This function will return true for both literal strings and strings created as instances of the String object.

Note that while this will return true for strings created using String(x), it will return false for objects created with new String(x). The latter are not considered strings, and typeof will return "object" for them rather than "string".

Parameters:
Name Type Description
x *

The value to be tested to see if it is a string.

Returns:

Either true if the value is a string or false if it is not.

Type
boolean