JsExtensions Class
This is not a class, but contains some methods that will be added to the standard Javascript objects.
Item Index
Methods
Array.prototype.clone () Array
Makes a shallow copy of the array.
Returns:
Array:
A shallow copy of the array
Array.prototype.contains ( element ) Boolean
Checks whether the array contains a given element.
Parameters:
-
element
AnyThe element to search for
Returns:
Boolean:
True if the array contains a given element
Array.prototype.equals ( array ) Boolean
Checks whether the two arrays are same.
Parameters:
-
array
AnyThe array to compare to
Returns:
Boolean:
True if the two arrays are same
Math.randomInt ( max ) Number [static]
Generates a random integer in the range (0, max-1).
Parameters:
-
max
NumberThe upper boundary (excluded)
Returns:
Number:
A random integer
Number.prototype.clamp ( min , max ) Number
Returns a number whose value is limited to the given range.
Parameters:
-
min
NumberThe lower boundary
-
max
NumberThe upper boundary
Returns:
Number:
A number in the range (min, max)
Number.prototype.mod ( n ) Number
Returns a modulo value which is always positive.
Parameters:
-
n
NumberThe divisor
Returns:
Number:
A modulo value
Number.prototype.padZero ( length ) String
Makes a number string with leading zeros.
Parameters:
-
length
NumberThe length of the output string
Returns:
String:
A string with leading zeros
String.prototype.contains ( string ) Boolean
Checks whether the string contains a given string.
Parameters:
-
string
StringThe string to search for
Returns:
Boolean:
True if the string contains a given string
String.prototype.format ( ...args ) String
Replaces %1, %2 and so on in the string to the arguments.
Parameters:
-
...args
AnyThe objects to format
Returns:
String:
A formatted string
String.prototype.padZero ( length ) String
Makes a number string with leading zeros.
Parameters:
-
length
NumberThe length of the output string
Returns:
String:
A string with leading zeros