Namespace: JsExtensions

JsExtensions

This section contains some methods that will be added to the standard Javascript objects.

Methods

Array#clone ()array static

Makes a shallow copy of the array.

Returns:
Type Description
array A shallow copy of the array.

Array#contains (element)boolean Deprecated : includes() should be used instead. static

Checks whether the array contains a given element.

Name Type Description
element any

The element to search for.

Returns:
Type Description
boolean True if the array contains a given element.

Array#equals (array)boolean static

Checks whether the two arrays are the same.

Name Type Description
array array

The array to compare to.

Returns:
Type Description
boolean True if the two arrays are the same.

Array#remove (element)array static

Removes a given element from the array (in place).

Name Type Description
element any

The element to remove.

Returns:
Type Description
array The array after remove.

Math.randomInt (max)number static

Generates a random integer in the range (0, max-1).

Name Type Description
max number

The upper boundary (excluded).

Returns:
Type Description
number A random integer.

Number#clamp (min, max)number static

Returns a number whose value is limited to the given range.

Name Type Description
min number

The lower boundary.

max number

The upper boundary.

Returns:
Type Description
number A number in the range (min, max).

Number#mod (n)number static

Returns a modulo value which is always positive.

Name Type Description
n number

The divisor.

Returns:
Type Description
number A modulo value.

Number#padZero (length)string static

Makes a number string with leading zeros.

Name Type Description
length number

The length of the output string.

Returns:
Type Description
string A string with leading zeros.

String#contains (string)boolean Deprecated : includes() should be used instead. static

Checks whether the string contains a given string.

Name Type Description
string string

The string to search for.

Returns:
Type Description
boolean True if the string contains a given string.

String#format ()string static

Replaces %1, %2 and so on in the string to the arguments.

Name Type Description
...args any

The objects to format.

Returns:
Type Description
string A formatted string.

String#padZero (length)string static

Makes a number string with leading zeros.

Name Type Description
length number

The length of the output string.

Returns:
Type Description
string A string with leading zeros.