Namespace: JsExtensions

JsExtensions

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

Methods

JsExtensions.Array#clone()arraystatic

Makes a shallow copy of the array
Returns:
TypeDescription
arrayA shallow copy of the array

JsExtensions.Array#contains(element)booleanDeprecated: includes() should be used insteadstatic

Checks whether the array contains a given element
NameTypeDescription
elementanyThe element to search for
Returns:
TypeDescription
booleanTrue if the array contains a given element

JsExtensions.Array#equals(array)booleanstatic

Checks whether the two arrays are the same
NameTypeDescription
arrayarrayThe array to compare
Returns:
TypeDescription
booleanTrue if the two arrays are the same

JsExtensions.Array#remove(element)arraystatic

Removes a given element from the array (in place)
NameTypeDescription
elementanyThe element to remove
Returns:
TypeDescription
arrayThe array after removal

JsExtensions.Math.randomInt(max)numberstatic

Generates a random integer in the range (0, max-1)
NameTypeDescription
maxnumberThe upper boundary (excluded)
Returns:
TypeDescription
numberA random integer

JsExtensions.Number#clamp(min, max)numberstatic

Returns a number whose value is limited to the given range
NameTypeDescription
minnumberThe lower boundary
maxnumberThe upper boundary
Returns:
TypeDescription
numberA number within the range (min, max).

JsExtensions.Number#mod(n)numberstatic

Returns a modulo value which is always positive
NameTypeDescription
nnumberThe divisor
Returns:
TypeDescription
numberA modulo value

JsExtensions.Number#padZero(length)stringstatic

Makes a number string with leading zeros
NameTypeDescription
lengthnumberThe length of the output string
Returns:
TypeDescription
stringA string with leading zeros

JsExtensions.String#contains(string)booleanDeprecated: includes() should be used insteadstatic

Checks whether the string contains a given string
NameTypeDescription
stringstringThe string to search for
Returns:
TypeDescription
booleanTrue if the string contains a given string

JsExtensions.String#format()stringstatic

Replaces %1, %2 and so on in the string to the arguments
NameTypeDescription
...argsanyThe objects to format
Returns:
TypeDescription
stringA formatted string

JsExtensions.String#padZero(length)stringstatic

Makes a number string with leading zeros
NameTypeDescription
lengthnumberThe length of the output string
Returns:
TypeDescription
stringA string with leading zeros