JavaScript Methods
JavaScript methods are the built-in actions you call on values — transforming an array with map(), splitting text with split(), reading an object's keys with Object.keys() and hundreds more. All 93 methods below link to a full page with its parameters, return value and a live example you can run right here.
| Name | Description |
|---|---|
| array.at() | Returns the element at a given index, accepting negative indices to count from the end. |
| array.concat() | Merges two or more arrays into a new array without changing any of the originals. |
| array.every() | Tests whether every element passes a check, returning true or false. |
| array.fill() | Fills all or part of an array with a static value, in place. |
| array.filter() | Creates a new array containing only the elements that pass a test you define in a callback function. |
| array.find() | Returns the first element that passes a test, or undefined if none do. |
| array.findIndex() | Returns the index of the first element that passes a test, or -1 if none do. |
| array.findLast() | Returns the last element that passes a test, searching from the end of the array. |
| array.findLastIndex() | Returns the index of the last element that passes a test, searching from the end, or -1. |
| array.flat() | Flattens nested arrays into a single array, up to a depth you choose. |
| array.flatMap() | Maps each element with a callback, then flattens the result one level deep, in a single pass. |
| array.forEach() | Runs a function once for each element of an array. Used for side effects, not for building a new array. |
| Array.from() | Creates a new array from an iterable or array-like value, with an optional map function. |
| array.includes() | Checks whether an array contains a given value, returning true or false. |
| array.indexOf() | Returns the first index at which a value is found in an array, or -1 if it is not present. |
| Array.isArray() | Returns true if a value is an array, and false otherwise. The reliable way to detect arrays. |
| array.join() | Joins all elements of an array into a single string, separated by a string you choose. |
| array.map() | Creates a new array by running a function on every element of the original and collecting the results. |
| array.pop() | Removes the last element from an array and returns it. Mutates the array. |
| array.push() | Adds one or more elements to the end of an array and returns the new length. |
| array.reduce() | Boils an array down to a single value by accumulating a result across every element. |
| array.reverse() | Reverses the order of an array's elements in place and returns the same array. |
| array.shift() | Removes the first element from an array and returns it, shifting the rest down. Mutates the array. |
| array.slice() | Returns a shallow copy of part of an array, selected from start to end, without changing the original. |
| array.some() | Tests whether at least one element passes a check, returning true or false. |
| array.sort() | Sorts the elements of an array in place. Sorts as text by default, so numbers need a compare function. |
| array.splice() | Changes an array in place by removing, replacing or inserting elements at a given index. |
| array.toReversed() | Returns a new reversed array without changing the original. The non-mutating version of reverse(). |
| array.toSorted() | Returns a new sorted array without changing the original. The non-mutating version of sort(). |
| array.toSpliced() | Returns a new array with elements removed or inserted, without changing the original. |
| array.unshift() | Adds one or more elements to the beginning of an array and returns the new length. Mutates the array. |
| array.with() | Returns a copy of an array with one index changed to a new value, without mutating the original. |
| Date.now() | Returns the current time as the number of milliseconds since January 1, 1970 (the Unix epoch). |
| date.toISOString() | Formats a date as a standard ISO 8601 string in UTC — ideal for storing and sending dates. |
| date.toLocaleDateString() | Formats a date as a readable string in the user's locale, with control over the style. |
| JSON.parse() | Parses a JSON string into a JavaScript value such as an object or array. |
| JSON.stringify() | Converts a JavaScript value into a JSON string for storage or sending over the network. |
| Math.abs() | Returns the absolute value of a number — its distance from zero, always non-negative. |
| Math.ceil() | Rounds a number up to the nearest integer, toward positive infinity. |
| Math.floor() | Rounds a number down to the nearest integer, toward negative infinity. |
| Math.hypot() | Returns the square root of the sum of squares of its arguments — the straight-line distance. |
| Math.max() | Returns the largest of the numbers passed to it. Spread an array to find its maximum. |
| Math.min() | Returns the smallest of the numbers passed to it. Spread an array to find its minimum. |
| Math.pow() | Raises a base number to an exponent. The ** operator does the same thing. |
| Math.random() | Returns a pseudo-random floating-point number from 0 (inclusive) up to 1 (exclusive). |
| Math.round() | Rounds a number to the nearest integer, with halves rounding up. |
| Math.sign() | Returns the sign of a number: -1 for negative, 1 for positive, 0 for zero. |
| Math.sqrt() | Returns the square root of a number, or NaN for negative input. |
| Math.trunc() | Removes the fractional part of a number, returning just the integer part (toward zero). |
| Number.isFinite() | Returns true only if a value is a finite number — not Infinity, -Infinity or NaN. |
| Number.isInteger() | Returns true if a value is an integer (a whole number), and false otherwise. |
| Number.isNaN() | Reliably checks whether a value is the special NaN value, without the global isNaN() coercion bug. |
| number.toFixed() | Formats a number with a fixed number of decimal places and returns it as a string. |
| Object.assign() | Copies properties from one or more source objects into a target object and returns the target. |
| Object.create() | Creates a new object with a specified prototype, the low-level basis of inheritance. |
| Object.entries() | Returns an array of an object's [key, value] pairs, perfect for looping over both at once. |
| Object.freeze() | Freezes an object so its properties can no longer be added, removed or changed. |
| Object.fromEntries() | Builds an object from a list of [key, value] pairs. The inverse of Object.entries(). |
| Object.hasOwn() | Checks whether an object has a property as its own (not inherited), returning true or false. |
| Object.keys() | Returns an array of an object's own property names (its keys), in insertion order. |
| Object.values() | Returns an array of an object's own property values, in insertion order. |
| parseFloat() | Parses a string and returns a floating-point number, including decimals. |
| parseInt() | Parses a string and returns an integer, stopping at the first character that is not a digit. |
| Promise.all() | Waits for several promises to all fulfill, returning their results — or rejects if any one fails. |
| Promise.allSettled() | Waits for all promises to settle and reports each result, whether it fulfilled or rejected. |
| Promise.any() | Resolves with the first promise to fulfill, ignoring rejections unless they all fail. |
| Promise.race() | Settles as soon as the first promise settles, with that promise's result or error. |
| Promise.resolve() | Returns a promise that is already fulfilled with a given value. |
| string.at() | Returns the character at a given index, accepting negative indices to count from the end. |
| string.charAt() | Returns the character at a given index in a string, or an empty string if out of range. |
| string.charCodeAt() | Returns the UTF-16 code (a number) of the character at a given index. |
| string.codePointAt() | Returns the full Unicode code point at an index, correctly handling emoji and astral characters. |
| string.endsWith() | Checks whether a string ends with a given substring, returning true or false. |
| string.includes() | Checks whether a string contains another string, returning true or false. Case-sensitive. |
| string.indexOf() | Returns the index of the first occurrence of a substring, or -1 if it is not found. |
| string.localeCompare() | Compares two strings in the current locale, returning a number for sorting alphabetically. |
| string.match() | Searches a string with a regular expression and returns the matches, or null if none. |
| string.matchAll() | Returns an iterator of all regex matches, including capture groups, for a global pattern. |
| string.padEnd() | Pads the end of a string with another string until it reaches a target length. |
| string.padStart() | Pads the start of a string with another string until it reaches a target length. |
| string.repeat() | Returns a new string made of the original repeated a given number of times. |
| string.replace() | Returns a new string with the first match of a pattern replaced. Use a regex with the g flag to replace all. |
| string.replaceAll() | Returns a new string with every match of a pattern replaced. The clear way to replace all occurrences. |
| string.slice() | Extracts part of a string into a new string, from a start index up to (not including) an end index. |
| string.split() | Splits a string into an array of substrings, breaking on a separator you choose. |
| string.startsWith() | Checks whether a string begins with a given substring, returning true or false. |
| string.substring() | Returns the part of a string between two indices. Similar to slice() but without negative indices. |
| string.toLowerCase() | Returns a new string with all characters converted to lowercase. |
| string.toUpperCase() | Returns a new string with all characters converted to uppercase. |
| string.trim() | Removes whitespace from both ends of a string. Essential for cleaning up user input. |
| string.trimEnd() | Removes whitespace from the end of a string only. |
| string.trimStart() | Removes whitespace from the beginning of a string only. |
| structuredClone() | Creates a deep copy of a value, including nested objects, arrays, Maps, Dates and more. |