The definitive JavaScript quick-reference for beginners and experts alike.
Makes a new empty array.
Makes a new array filled with the elements you pass in.
Makes a sparse array with empty slots.
Converts any value to a string. Works with numbers, booleans, objects, null, undefined, and more.
Creates the number 0. Called without arguments, always returns zero. Rarely used since you can...
Converts any value to a number. Returns NaN for values that cannot be converted. More strict...
Creates a boolean with the value false. Called without arguments, it always returns false.
Converts any value to true or false based on its "truthiness". There are exactly 8 falsy values...
Creates an empty object. Equivalent to using object literal syntax {}. Rarely used since {} is...
Wraps a primitive value in an object wrapper, or returns the object unchanged if already an...
Creates a Date object for the current local date and time. In practice, use `new Date()` to...
Creates a Date object from one value: a date string, a timestamp in milliseconds, or another...
Creates a Date object from numeric date/time components in local time (month is 0-based).
Makes a RegExp object that matches an empty string (equivalent to `/(?:)/`).
Makes a RegExp object using the given pattern (as a string or another RegExp) and optional flags...
Creates an empty Map. Use `new Map()` when constructing it.
Creates a Map populated with key-value pairs from an iterable (for example, an array of `[key,...
Creates an empty Set. Use `new Set()` when constructing it.
Creates a Set populated with unique values from an iterable (for example, an array, string, or...
Creates a Promise that represents an async operation. You must call this with `new`. The...
Checks if a value is an array. Returns true for arrays, false for everything else (objects,...
Converts things like strings or array-like objects into real arrays. You can also transform each...
Makes an array with whatever elements you pass in, no matter how many or what type. Unlike...
Creates a string from UTF-16 code units. Each number becomes one character. Common codes: 65-90...
Creates a string from Unicode code points. Similar to fromCharCode but supports emojis and...
Returns a string where backslashes are not treated as escape characters. Useful for regex...
The smallest number greater than 1 that can be represented as an IEEE 754 double precision...
The largest integer that can be safely represented without losing precision (2^53 - 1, or...
The largest positive representable number (approximately 1.7976931348623157e+308).
The smallest integer that can be safely represented without losing precision (-(2^53 - 1), or...
The smallest positive representable number (approximately 5e-324).
The special "Not a Number" value.
The special negative infinite value (-∞).
The special positive infinite value (+∞).
Provides the Number prototype from which all Numbers inherit.
Checks if a value is a finite number. Returns false for Infinity, -Infinity, NaN, and...
Checks if a value is a whole number (no decimal part). Does not coerce - strings and other types...
Checks if a value is exactly NaN. Only returns true for the NaN value itself. Much better than...
Returns `true` if the given value is an integer safe for arithmetic operations (within...
Parses a string and returns a decimal number. Stops at the first non-numeric character. More...
Parses a string and returns an integer. Always specify the radix (base) to avoid surprises....
Copies properties from source objects into the target object. Later sources overwrite earlier...
Creates a new object with the specified prototype. Use null for an object with no prototype (no...
Defines a new or modifies an existing property on the object with the given descriptor.
Defines or modifies multiple properties on the object using an object of property descriptors.
Returns an array of [key, value] pairs for an object. Perfect for iterating over objects with...
Makes an object completely immutable. Cannot add, remove, or modify properties. Only freezes the...
Makes an object from an iterable of key-value pairs (e.g., from Array.entries() or Map.entries()).
Returns the property descriptor for the given own property of the object (or undefined if not...
Returns an object containing all own property descriptors of the object.
Returns an array of all own string property names (including non-enumerable ones) of the object....
Returns an array of all own symbol properties of the object.
Returns the prototype of the given object.
Returns `true` if the object has the given property as its own (not inherited), otherwise `false`.
Compares two values for exact equality, handling special cases like NaN (unlike strict equality...
Returns `true` if the object is extensible (can have new properties added), otherwise `false`.
Returns `true` if the object is frozen, otherwise `false`.
Returns `true` if the object is sealed, otherwise `false`.
Returns an array of an object's own property names (keys). Does not include inherited properties...
Prevents new properties from being added to the object (makes it non-extensible).
Seals the object, preventing new properties from being added and making existing properties...
Sets the prototype of the object to the given prototype object.
Returns an array of an object's own property values. Does not include inherited properties or...
Returns the current timestamp as the number of milliseconds since the Unix epoch (January 1,...
Parses a string representation of a date and returns the number of milliseconds since the Unix...
Returns the number of milliseconds since the Unix epoch for the given UTC date components (month...
The base of the natural logarithm (Euler's constant, approximately 2.718281828459045).
The natural logarithm of 10 (approximately 2.302585092994046).
The natural logarithm of 2 (approximately 0.6931471805599453).
The base-10 logarithm of E (approximately 0.4342944819032518).
The base-2 logarithm of E (approximately 1.4426950408889634).
The ratio of a circle's circumference to its diameter (approximately 3.141592653589793).
The square root of 1/2 (approximately 0.7071067811865476).
The square root of 2 (approximately 1.4142135623730951).
Returns the absolute value of the given number (removes the sign).
Returns the arccosine (inverse cosine) of the given number (in radians, 0 to π).
Returns the hyperbolic arccosine (inverse hyperbolic cosine) of the given number (in radians;...
Returns the arcsine (inverse sine) of the given number (in radians, -π/2 to π/2).
Returns the hyperbolic arcsine (inverse hyperbolic sine) of the given number (in radians).
Returns the arctangent (inverse tangent) of the given number (in radians, -π/2 to π/2).
Returns the arctangent of the quotient y/x (in radians, -π to π), accounting for the correct...
Returns the cube root of the given number.
Returns the smallest integer greater than or equal to the given number (rounds up).
Returns the number of leading zero bits in the 32-bit integer representation of the given number.
Returns the cosine of the given number (in radians).
Returns the hyperbolic cosine of the given number.
Returns e^x, where x is the given number (Euler's number raised to the power).
Returns the result of subtracting 1 from e^x (more precise for small x than `exp(x) - 1`).
Returns the largest integer less than or equal to the given number (rounds down).
Returns the nearest single-precision (32-bit) float representation of the given number.
Returns the square root of the sum of squares of the given numbers (Euclidean distance; avoids...
Returns the 32-bit integer result of multiplying two numbers (as if both were 32-bit signed...
Returns the natural logarithm (base e) of the given number (value > 0).
Returns the base-10 logarithm of the given number (value > 0).
Returns the natural logarithm of 1 + x (more precise for small x than `log(1 + x)`).
Returns the base-2 logarithm of the given number (value > 0).
Returns the largest of the given numbers (returns `NaN` if any argument is `NaN`).
Returns the smallest of the given numbers (returns `NaN` if any argument is `NaN`).
Returns the result of raising the base to the exponent power.
Returns a pseudo-random number between 0 (inclusive) and 1 (exclusive).
Returns the value rounded to the nearest integer. If the fractional part is exactly 0.5, it...
Returns the sign of the given number: -1 for negative, 0 for zero, 1 for positive, or -0 for...
Returns the sine of the given number (in radians).
Returns the hyperbolic sine of the given number.
Returns the positive square root of the given number (value ≥ 0).
Returns the tangent of the given number (in radians).
Returns the hyperbolic tangent of the given number.
Returns the integer part of the given number (truncates the decimal portion without rounding).
Provides the RegExp prototype from which all RegExps inherit.
Converts a JSON string into a JavaScript value (object, array, string, number, boolean, or...
Converts a JavaScript value to a JSON string. Functions, undefined, and Symbols are omitted (or...
Waits for all promises to complete. If all succeed, resolves with an array of all results (in...
Waits for all promises to complete (success or failure). Never rejects - always returns a result...
Resolves as soon as any promise succeeds (first one wins). Only rejects if all promises fail,...
The first promise to settle (success or failure) wins. Unlike any(), a rejection can win. Useful...
Creates a Promise that immediately rejects with the given reason. Useful for returning early...
Creates a Promise that immediately resolves with the given value. Useful for wrapping...
Most commonly used methods for working with JavaScript data
Returns the element at the index. Supports negative indices to count from the end (-1 is the...
Combines the array with one or more other arrays or values, returns a new array without...
Copies a portion of the array to another location within the same array, overwriting existing...
Returns an iterator that yields [index, value] pairs. Useful when you need both the index and...
Checks whether every element passes a test. Returns `true` only if all elements pass, and...
Fills all or part of the array with a value. Start and end indices are optional.
Makes an array with elements that pass the given filtering function (optionally with a `this`...
Returns the first element that passes the test function. Returns undefined if no element passes.
Returns the index of the first element that passes the test function. Returns -1 if no element...
Returns the last element that passes the test function (searches from end to start). Returns...
Returns the index of the last element that passes the test function (searches from end to...
Creates a new array with all sub-arrays "flattened" into it. Depth controls how many levels deep...
Maps each element using a function, then flattens the result by one level. Same as calling map()...
Runs a function once for each element. Does not return anything (undefined). Use for side...
Checks if the array contains a specific value. Uses strict equality (===), so objects must be...
Returns the first index where the value is found, or -1 if not found. Uses strict equality (===).
Combines all elements into a single string, with an optional separator between them. Default...
Returns an iterator that yields the index (0, 1, 2, ...) for each element in the array.
Returns the last index where the value is found, searching backwards. Returns -1 if not found.
Creates a new array by calling a function on every element. The new array has the same length,...
Removes and returns the last element from the array. Changes the original array. Returns...
Adds one or more elements to the end of the array. Returns the new length. Changes the original...
Reduces the array to a single value by calling a function on each element, passing the result to...
Same as reduce(), but processes elements from right to left instead of left to right.
Reverses the array in place and returns it. The first element becomes last, the last becomes first.
Removes and returns the first element from the array. Changes the original array. All other...
Returns a shallow copy of a portion of the array. Does not modify the original. Supports...
Checks whether at least one element passes a test. Returns true as soon as one passes, and false...
Sorts the array in place. Without a compare function, elements are converted to strings and...
The Swiss Army knife of array modification. Can remove elements, add elements, or both at any...
Returns a new array with elements in reversed order. Does not modify the original (unlike...
Returns a new sorted array. Does not modify the original (unlike sort()). The same compare...
Returns a new array with elements removed or added. Does not modify the original (unlike splice()).
Adds one or more elements to the beginning of the array. Returns the new length. All existing...
Returns an iterator that yields each value in the array. This is the default iterator used by...
Returns a new array with the element at the given index replaced. Does not modify the original....
Returns the character at the given index. Supports negative indices to count from the end (-1 is...
Returns the character at the given index. Similar to at() but returns empty string instead of...
Returns the UTF-16 code unit (0-65535) at the given index. Use with String.fromCharCode() to...
Returns the Unicode code point at the given index. Unlike charCodeAt, works with emojis and...
Joins two or more strings together and returns a new string. The + operator or template literals...
Checks if the string ends with the given characters. The optional length parameter lets you...
Checks if the string contains the given substring anywhere. Case-sensitive.
Returns the index of the first occurrence of a substring. Returns -1 if not found. Case-sensitive.
Returns `true` if this string does not contain lone surrogates, otherwise `false`.
Returns the index of the last occurrence of the given value in the string.
Compares two strings using locale-aware sort rules and returns whether the reference string...
Retrieves the result of matching a string against a regular expression.
Returns an iterator of all results matching a string against a regular expression, including...
Returns the Unicode Normalization Form of the string.
Pads the end of the string with another string until it reaches the target length. If already at...
Pads the beginning of the string with another string until it reaches the target length. If...
Returns a new string with the original string repeated the specified number of times.
Replaces the first occurrence of a pattern with a replacement. Use replaceAll() or regex with /g...
Replaces all occurrences of a pattern with a replacement. Simpler than `replace()` with a global...
Searches for a match between a regular expression and the string.
Extracts a section of the string and returns it as a new string. Supports negative indices. Does...
Splits a string into an array of substrings using a separator. The separator can be a string or...
Checks if the string starts with the given characters. The optional position lets you check from...
Returns the part of the string between two indices. Similar to slice() but treats negative...
Returns this string converted to lower case, according to any locale-specific case mappings.
Returns this string converted to upper case, according to any locale-specific case mappings.
Returns this string converted to lower case.
Returns the primitive string value. Useful when you are working with a String object wrapper.
Returns this string converted to upper case.
Returns a string where all lone surrogates of this string are replaced with the Unicode...
Removes whitespace from both ends of a string and returns a new string, without modifying the...
Removes whitespace from the end of a string and returns a new string, without modifying the...
Removes whitespace from the beginning of a string and returns a new string, without modifying...
Returns the primitive value of a String object.
Returns an Iterator object for iterating over the code points of the string, returning each code...
Formats a number in scientific/exponential notation (e.g., 1.23e+4 means 1.23 × 10⁴). Useful for...
Formats a number with exactly the specified number of decimal places. Rounds if needed. Returns...
Returns a locale-specific string representation of the number (e.g., formatted with commas or...
Returns a string representing the number to the given precision (significant digits, 1-21; uses...
Converts a number to a string. Optionally specify a base (radix) for binary, hex, octal, etc.
Returns the primitive number value of the Number object.
Converts a boolean to its string representation: "true" or "false".
Returns the primitive boolean value. Rarely needed since JavaScript auto-converts, but important...
Returns `true` if the object has the given property as its own (ignores the prototype chain),...
Returns `true` if the object is in the prototype chain of the given object, otherwise `false`.
Returns `true` if the given property is enumerable, otherwise `false`.
Returns a locale-specific string representation of the object.
Returns a string representation of the object.
Returns the object's primitive value. For plain objects, this is usually the object itself.
Customizes the `instanceof` operator by defining how to check if an object is an instance of a...
Determines if the object should be flattened when used with `Array.prototype.concat`.
Returns an iterator for iterating over the object's values.
Customizes the behavior of `String.prototype.match` when the object is used as a RegExp-like...
Customizes the behavior of `String.prototype.replace` when the object is used as a RegExp-like...
Customizes the behavior of `String.prototype.search` when the object is used as a RegExp-like...
Specifies a constructor to use for derived objects.
Customizes the behavior of `String.prototype.split` when the object is used as a RegExp-like...
Returns a primitive value representation of the object, given a hint.
Provides a string tag for the object, used in `toString`.
Returns an object whose properties are excluded from the `with` environment bindings.
Returns the day of the month (1-31) for the date.
Returns the day of the week (0-6, where 0 is Sunday) for the date.
Returns the four-digit year for the date.
Returns the hour (0-23) for the date.
Returns the milliseconds (0-999) for the date.
Returns the minutes (0-59) for the date.
Returns the month (0-11) for the date.
Returns the seconds (0-59) for the date.
Returns the number of milliseconds since the Unix epoch for the date.
Returns the time zone difference in minutes from UTC for the date.
Returns the day of the month (1-31) for the UTC date.
Returns the day of the week (0-6) for the UTC date.
Returns the four-digit year for the UTC date.
Returns the hour (0-23) for the UTC date.
Returns the milliseconds (0-999) for the UTC date.
Returns the minutes (0-59) for the UTC date.
Returns the month (0-11) for the UTC date.
Returns the seconds (0-59) for the UTC date.
Sets the day of the month for the date and returns the new timestamp (adjusts month/year if needed).
Sets the year (and optional month/day) for the date and returns the new timestamp.
Sets the hours (and optional minutes/seconds/milliseconds) for the date and returns the new...
Sets the milliseconds for the date and returns the new timestamp.
Sets the minutes (and optional seconds/milliseconds) for the date and returns the new timestamp.
Sets the month (and optional day) for the date and returns the new timestamp (adjusts year if...
Sets the seconds (and optional milliseconds) for the date and returns the new timestamp.
Sets the date to the given timestamp (milliseconds since epoch) and returns the new timestamp.
Sets the UTC day of the month for the date and returns the new timestamp.
Sets the UTC year (and optional month/day) for the date and returns the new timestamp.
Sets the UTC hours (and optional minutes/seconds/milliseconds) for the date and returns the new...
Sets the UTC milliseconds for the date and returns the new timestamp.
Sets the UTC minutes (and optional seconds/milliseconds) for the date and returns the new timestamp.
Sets the UTC month (and optional day) for the date and returns the new timestamp.
Sets the UTC seconds (and optional milliseconds) for the date and returns the new timestamp.
Returns a string representing the date portion in the local timezone (e.g., "Tue Nov 21 2023").
Returns a string representing the date in ISO 8601 format (UTC, e.g., "2023-11-21T12:34:56.789Z").
Returns a JSON-safe string representation of the date (equivalent to `toISOString()` for...
Returns a locale-specific string representing the date portion (e.g., "11/21/2023" in en-US).
Returns a locale-specific string representing the full date and time.
Returns a locale-specific string representing the time portion (e.g., "12:34:56 PM").
Returns a string representing the full date and time in the local timezone...
Returns a string representing the time portion in the local timezone (e.g., "12:34:56 GMT-0500...
Returns a string representing the date in UTC (RFC 1123 format, e.g., "Tue, 21 Nov 2023 17:34:56...
Returns the primitive timestamp value (milliseconds since epoch) of the Date object (same as...
Returns `true` if the dot (`.`) matches newlines (`s` flag), otherwise `false`.
A string with the flags of the RegExp (e.g., "gi").
Returns `true` if the `g` flag is set (matches all occurrences), otherwise `false`.
Returns `true` if the `d` flag is set (provides match indices), otherwise `false`.
Returns `true` if the `i` flag is set (case-insensitive matching), otherwise `false`.
The index where to start the next match (used with global or sticky; writable).
Returns `true` if the `m` flag is set (treats `^` and `$` as line boundaries), otherwise `false`.
The source pattern of the RegExp (as a string, escaped for literal use).
Returns `true` if the `y` flag is set (matches starting at `lastIndex` only), otherwise `false`.
Returns `true` if the `u` flag is set (enables Unicode features like full code point support),...
Customizes the behavior when the RegExp is used with `String.prototype.match` (returns matches...
Customizes the behavior when the RegExp is used with `String.prototype.matchAll` (returns an...
Customizes the behavior when the RegExp is used with `String.prototype.replace` (replaces matches).
Customizes the behavior when the RegExp is used with `String.prototype.search` (returns index of...
Customizes the behavior when the RegExp is used with `String.prototype.split` (splits on matches).
Executes the RegExp on the given string, returning an array of match details (including groups...
Tests the string against the RegExp, returning true if there is a match or false otherwise;...
Returns a string representation of the RegExp (e.g., `/pattern/flags`).
A read-only property representing the number of key-value pairs in the Map.
Removes all key-value pairs from the Map (changes the original).
Removes the given key and its value from the Map (returns `true` if successful, `false` if key...
Runs a given function once for each key-value pair (callback receives value, key, and Map as...
Returns the value associated with the given key, or `undefined` if the key doesn't exist.
Returns `true` if the Map contains the given key, otherwise `false`.
Returns an Iterator object for iterating over the keys in the order they were added.
Adds or updates the key-value pair in the Map and returns the Map itself (mutates original;...
Returns an Iterator object for iterating over the values in the order they were added.
Returns an Iterator object for iterating over key-value pairs in the order they were added.
Returns an Iterator object for iterating over key-value pairs in the order they were added (lets...
Provides the string tag "Map", which is used by `Object.prototype.toString.call(...)`.
A read-only property representing the number of values in the Set.
Appends the given value to the Set (if not already present) and returns the Set itself (mutates...
Removes all values from the Set (changes the original).
Removes the given value from the Set (returns `true` if successful, `false` if value not found;...
Runs a given function once for each value (callback receives value, same value as key, and Set...
Returns `true` if the Set contains the given value, otherwise `false`.
Returns an Iterator object for iterating over the values in the order they were added (identical...
Returns an Iterator object for iterating over the values in the order they were added.
Returns an Iterator object for iterating over [value, value] pairs in the order they were added...
Returns an Iterator object for iterating over the values in the order they were added (lets you...
Provides the string tag "Set", which is used by `Object.prototype.toString.call(...)`.
Handles errors from the Promise chain. Like a try/catch for promises. Returns a new Promise so...
Runs cleanup code no matter if the promise succeeds or fails. The handler receives no arguments...
The main way to handle Promise results. Chain .then() calls to process data step by step. Each...