JavaScript Core Functions Reference

Category Function Description
Core JavaScript Functions eval(string) Evaluates JavaScript code represented as a string.
parseInt(string, radix) Converts a string to an integer, optionally specifying the base (radix).
parseFloat(string) Converts a string to a floating-point number.
isNaN(value) Determines whether a value is NaN (Not-a-Number).
isFinite(value) Determines whether a value is a finite number.
encodeURI(uri) Encodes a Uniform Resource Identifier (URI) by escaping certain characters.
decodeURI(uri) Decodes a URI encoded by encodeURI.
encodeURIComponent(uriComponent) Encodes a URI component by escaping characters.
decodeURIComponent(uriComponent) Decodes a URI component encoded by encodeURIComponent.
escape(string) (Deprecated) Encodes a string for use in URLs.
unescape(string) (Deprecated) Decodes a string encoded by escape.
Math Functions Math.abs(x) Returns the absolute value of a number.
Math.ceil(x) Rounds a number upward to the nearest integer.
Math.floor(x) Rounds a number downward to the nearest integer.
Math.round(x) Rounds a number to the nearest integer.
Math.random() Returns a pseudo-random number between 0 (inclusive) and 1 (exclusive).
Math.max(...values) Returns the largest of zero or more numbers.
Math.min(...values) Returns the smallest of zero or more numbers.
Math.pow(base, exponent) Returns the base raised to the power of the exponent.
Math.sqrt(x) Returns the square root of a number.
Math.trunc(x) Returns the integer part of a number by removing the fractional part.
String Methods String.fromCharCode(...codes) Converts Unicode values to a string.
str.charAt(index) Returns the character at the specified index in a string.
str.charCodeAt(index) Returns the Unicode of the character at the specified index.
str.concat(...strings) Combines two or more strings.
str.includes(substring) Checks if a string contains a substring.
str.indexOf(substring) Returns the position of the first occurrence of a specified value.
str.lastIndexOf(substring) Returns the position of the last occurrence of a specified value.
str.split(separator) Splits a string into an array of substrings.
str.slice(start, end) Extracts a section of a string.
str.toUpperCase() Converts a string to uppercase.
str.toLowerCase() Converts a string to lowercase.
str.trim() Removes whitespace from both ends of a string.
str.replace(searchValue, newValue) Replaces specified values in a string.
str.substring(start, end) Extracts characters between two indices in a string.
Array Methods Array.isArray(value) Checks if a value is an array.
arr.push(...items) Adds one or more elements to the end of an array.
arr.pop() Removes and returns the last element of an array.
arr.shift() Removes and returns the first element of an array.
arr.unshift(...items) Adds one or more elements to the beginning of an array.
arr.slice(start, end) Returns a shallow copy of a portion of an array.
arr.splice(start, deleteCount, ...items) Adds or removes elements from an array.
arr.concat(...arrays) Merges two or more arrays.
arr.indexOf(value) Returns the first index of a specified value.
arr.lastIndexOf(value) Returns the last index of a specified value.
arr.forEach(callback) Executes a function for each array element.
arr.map(callback) Creates a new array with results from a function.
arr.filter(callback) Returns a new array with elements that pass a test.
arr.reduce(callback, initialValue) Reduces an array to a single value.
arr.find(callback) Returns the first element that satisfies a test.
arr.findIndex(callback) Returns the index of the first element that satisfies a test.
arr.includes(value) Checks if an array includes a value.
arr.join(separator) Joins array elements into a string.
arr.sort(compareFunction) Sorts the elements of an array.
arr.reverse() Reverses the order of an array.
Date Methods Date.now() Returns the current timestamp in milliseconds.
new Date() Creates a new Date object.
date.getFullYear() Returns the year of a date.
date.getMonth() Returns the month (0-11) of a date.
date.getDate() Returns the day of the month.
date.getDay() Returns the day of the week (0-6).
date.getHours() Returns the hour of a date.
date.getMinutes() Returns the minutes of a date.
date.getSeconds() Returns the seconds of a date.
date.toISOString() Converts a date to an ISO string.




Advertisement