JavaScript Built-in Functions
What are Built-in functions in JavaScript?
Predefined functions are those that are already present in the language and can be used without requiring you to specify them. These features can be found in the JavaScript standard library, which is frequently utilized in applications.
Number Methods:
1) toExponential(): Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
2)toFixed(): Formats a number with a specific number of digits to the right of the decimal.
3)toLocaleString(): Returns a string value version of the current number in a format that may vary according to a browser’s locale settings.
4)toString(): Returns the string representation of the number’s value.
5)valueOf(): Returns the number’s value.
String Methods:
1)charAt(): Returns the character at the specified index.
2)charCodeAt(): Returns a number indicating the Unicode value of the character at the given index.
3)concat(): Combines the text of two strings and returns a new string.
4)indexOf(): Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
5)lastIndexOf(): Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
6)length(): Returns the length of the string.
7)replace(): Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
8)slice(): Extracts a section of a string and returns a new string.
9)substr(): Returns the characters in a string beginning at the specified location through the specified number of characters.
10)substring(): Returns the characters in a string between two indexes into the string.
11)toLowerCase(): Returns the calling string value converted to lower case.
12)toString(): Returns a string representing the specified object.
13)toUpperCase(): Returns the calling string value converted to uppercase.
Array Methods:
1)forEach(): Calls a function for each element in the array.
2)indexOf(): Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
3)join(): Joins all elements of an array into a string.
4)lastIndexOf(): Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
5)pop(): Removes the last element from an array and returns that element.
6)push(): Adds one or more elements to the end of an array and returns the new length of the array.
7)reverse(): Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first.
8)shift(): Removes the first element from an array and returns that element.
9)slice(): Extracts a section of an array and returns a new array.
10)sort(): Sorts the elements of an array.
11)unshift(): Adds one or more elements to the front of an array and returns the new length of the array.
Date Methods:
1)Date(): Returns today’s date and time.
2)getDate(): Returns the day of the month for the specified date according to local time.
3)getDay(): Returns the day of the week for the specified date according to local time.
4)getFullYear(): Returns the year of the specified date according to local time.
5)getHours(): Returns the hour in the specified date according to local time.
6)getMilliseconds(): Returns the milliseconds in the specified date according to local time.
7)getMinutes(): Returns the minutes in the specified date according to local time.
8)getMonth(): Returns the month in the specified date according to local time.
9)getSeconds(): Returns the seconds in the specified date according to local time.
10)getTime(): Returns the numeric value of the specified date as the number of milliseconds since January 1, 2024, 00:00:00 UTC.
Math Methods:
1)abs(): Returns the absolute value of a number.
2)ceil(): Returns the smallest integer greater than or equal to a number.
3)max(): Returns the largest of zero or more numbers.
4)min(): Returns the smallest of zero or more numbers.
5)pow(): Returns base to the exponent power, that is, base exponent.
6)random(): Returns a pseudo-random number between 0 and 1.
7)round(): Returns the value of a number rounded to the nearest integer.
8)sqrt(): Returns the square root of a number.