String Methods in JavaScript/TypeScript
A list of the methods available in String object along with their description is given below –
S.No.
|
Method & Description
|
1.
|
Returns the character at the specified index.
|
2.
|
Returns a number indicating the Unicode value of the character at the given index.
|
3.
|
Combines the text of two strings and returns a new string.
|
4.
|
Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
|
5.
|
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
|
6.
|
Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
|
7.
|
match()
Used to match a regular expression against a string.
|
8.
|
Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
|
9.
|
Executes the search for a match between a regular expression and a specified string.
|
10.
|
Extracts a section of a string and returns a new string.
|
11.
|
Splits a String object into an array of strings by separating the string into substrings.
|
12.
|
Returns the characters in a string beginning at the specified location through the specified number of characters.
|
13.
|
Returns the characters in a string between two indexes into the string.
|
14.
|
The characters within a string are converted to lower case while respecting the current locale.
|
15.
|
The characters within a string are converted to upper case while respecting the current locale.
|
16.
|
Returns the calling string value converted to lower case.
|
17.
|
Returns a string representing the specified object.
|
18.
|
Returns the calling string value converted to uppercase.
|
19.
|
Returns the primitive value of the specified object.
|
Number Methods in JavaScript/TypeScript
The Number object contains only the default methods that are a part of every object's definition. Some of the commonly used methods are listed below –
S.No.
|
Methods & Description
|
1.
|
Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
|
2.
|
Formats a number with a specific number of digits to the right of the decimal.
|
3.
|
Returns a string value version of the current number in a format that may vary according to a browser's local settings.
|
4.
|
Defines how many total digits (including digits to the left and right of the decimal) to display of a number. A negative precision will throw an error.
|
5.
|
Returns the string representation of the number's value. The function is passed the radix, an integer between 2 and 36 specifying the base to use for representing numeric values.
|
6.
|
Returns the number's primitive value.
|
Array Methods in JavaScript/TypeScript
A list of the methods of the Array object along with their description is given below.
S.No.
|
Method & Description
|
1.
|
Returns a new array comprised of this array joined with other array(s) and/or value(s).
|
2.
|
Returns true if every element in this array satisfies the provided testing function.
|
3.
|
Creates a new array with all of the elements of this array for which the provided filtering function returns true.
|
4.
|
Calls a function for each element in the array.
|
5.
|
Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
|
6.
|
Joins all elements of an array into a string.
|
7.
|
Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
|
8.
|
Creates a new array with the results of calling a provided function on every element in this array.
|
9.
|
Removes the last element from an array and returns that element.
|
10.
|
Adds one or more elements to the end of an array and returns the new length of the array.
|
11.
|
Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
|
12.
|
Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
|
13.
|
Reverses the order of the elements of an array -- the first becomes the last, and the last becomes the first.
|
14.
|
Removes the first element from an array and returns that element.
|
15.
|
Extracts a section of an array and returns a new array.
|
16.
|
Returns true if at least one element in this array satisfies the provided testing function.
|
17.
|
Sorts the elements of an array.
|
18.
|
Adds and/or removes elements from an array.
|
19.
|
Returns a string representing the array and its elements.
|
20.
|
Adds one or more elements to the front of an array and returns the new length of the array.
|
No comments:
Post a Comment