JavaScript Reference
Complete guide to JavaScript methods and properties
📚 Array (25)
map()
Creates a new array with the results of calling a provided function on every element in the calling array.
filter()
Creates a new array with all elements that pass the test implemented by the provided function.
reduce()
Executes a reducer function on each element of the array, resulting in a single output value.
forEach()
Executes a provided function once for each array element.
find()
Returns the first element in the array that satisfies the provided testing function.
findIndex()
Returns the index of the first element in the array that satisfies the provided testing function.
some()
Tests whether at least one element in the array passes the test implemented by the provided function.
every()
Tests whether all elements in the array pass the test implemented by the provided function.
includes()
Determines whether an array includes a certain value among its entries.
indexOf()
Returns the first index at which a given element can be found in the array.
slice()
Returns a shallow copy of a portion of an array into a new array object.
splice()
Changes the contents of an array by removing or replacing existing elements and/or adding new elements.
concat()
Merges two or more arrays into a new array.
join()
Creates and returns a new string by concatenating all elements in an array.
reverse()
Reverses an array in place and returns the reference to the same array.
sort()
Sorts the elements of an array in place and returns the sorted array.
push()
Adds one or more elements to the end of an array and returns the new length.
pop()
Removes the last element from an array and returns that element.
shift()
Removes the first element from an array and returns that element.
unshift()
Adds one or more elements to the beginning of an array and returns the new length.
flat()
Creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
flatMap()
Returns a new array formed by applying a given callback function to each element of the array, then flattening the result by one level.
fill()
Fills all the elements of an array from a start index to an end index with a static value.
Array.from()
Creates a new Array instance from an array-like or iterable object.
Array.isArray()
Determines whether the passed value is an Array.
📝 String (22)
split()
Divides a string into an ordered list of substrings and returns them as an array.
slice()
Extracts a section of a string and returns it as a new string.
substring()
Returns the part of the string between the start and end indexes.
toLowerCase()
Returns the string converted to lower case.
toUpperCase()
Returns the string converted to upper case.
trim()
Removes whitespace from both ends of a string.
trimStart()
Removes whitespace from the beginning of a string.
trimEnd()
Removes whitespace from the end of a string.
replace()
Returns a new string with some or all matches of a pattern replaced by a replacement.
replaceAll()
Returns a new string with all matches of a pattern replaced by a replacement.
includes()
Determines whether one string may be found within another string.
startsWith()
Determines whether a string begins with the characters of a specified string.
endsWith()
Determines whether a string ends with the characters of a specified string.
indexOf()
Returns the index of the first occurrence of a specified value in a string.
charAt()
Returns the character at the specified index in a string.
charCodeAt()
Returns the UTF-16 code unit at the specified index.
concat()
Concatenates the string arguments to the calling string.
repeat()
Returns a new string with a specified number of copies of the string.
padStart()
Pads the current string from the start with another string until the resulting string reaches the given length.
padEnd()
Pads the current string from the end with another string until the resulting string reaches the given length.
match()
Retrieves the result of matching a string against a regular expression.
search()
Executes a search for a match between a regular expression and this string.
📦 Object (15)
Object.keys()
Returns an array of a given object's own enumerable property names.
Object.values()
Returns an array of a given object's own enumerable property values.
Object.entries()
Returns an array of a given object's own enumerable property [key, value] pairs.
Object.fromEntries()
Transforms a list of key-value pairs into an object.
Object.assign()
Copies all enumerable own properties from one or more source objects to a target object.
Object.freeze()
Freezes an object, preventing new properties from being added and existing properties from being removed or changed.
Object.isFrozen()
Determines if an object is frozen.
Object.seal()
Seals an object, preventing new properties from being added and marking all existing properties as non-configurable.
Object.isSealed()
Determines if an object is sealed.
Object.create()
Creates a new object with the specified prototype object and properties.
hasOwnProperty()
Returns a boolean indicating whether the object has the specified property as its own property.
Object.getPrototypeOf()
Returns the prototype of the specified object.
Object.defineProperty()
Defines a new property directly on an object, or modifies an existing property.
Object.getOwnPropertyDescriptor()
Returns a property descriptor for an own property of a given object.
Object.getOwnPropertyNames()
Returns an array of all properties found directly in a given object.
🧮 Math (15)
Math.abs()
Returns the absolute value of a number.
Math.floor()
Returns the largest integer less than or equal to a given number.
Math.ceil()
Returns the smallest integer greater than or equal to a given number.
Math.round()
Returns the value of a number rounded to the nearest integer.
Math.trunc()
Returns the integer part of a number by removing any fractional digits.
Math.random()
Returns a floating-point, pseudo-random number in the range 0 to less than 1.
Math.max()
Returns the largest of the zero or more numbers given as input parameters.
Math.min()
Returns the smallest of the zero or more numbers given as input parameters.
Math.pow()
Returns the base to the exponent power.
Math.sqrt()
Returns the square root of a number.
Math.cbrt()
Returns the cube root of a number.
Math.sign()
Returns the sign of a number, indicating whether the number is positive, negative, or zero.
Math.sin()
Returns the sine of a number (in radians).
Math.cos()
Returns the cosine of a number (in radians).
Math.log()
Returns the natural logarithm (base e) of a number.
📅 Date (15)
Date.now()
Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
Date.parse()
Parses a string representation of a date and returns the number of milliseconds since UNIX epoch.
getTime()
Returns the number of milliseconds since January 1, 1970 00:00:00 UTC.
getFullYear()
Returns the year of the specified date according to local time.
getMonth()
Returns the month (0-11) in the specified date according to local time.
getDate()
Returns the day of the month (1-31) for the specified date according to local time.
getDay()
Returns the day of the week (0-6) for the specified date according to local time.
getHours()
Returns the hour (0-23) in the specified date according to local time.
getMinutes()
Returns the minutes (0-59) in the specified date according to local time.
getSeconds()
Returns the seconds (0-59) in the specified date according to local time.
getMilliseconds()
Returns the milliseconds (0-999) in the specified date according to local time.
toISOString()
Returns a string in ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ).
toLocaleString()
Returns a string with a language-sensitive representation of this date.
toLocaleDateString()
Returns the date portion of the Date as a string, using locale conventions.
setFullYear()
Sets the full year for a specified date according to local time.
🔄 JSON (5)
JSON.parse()
Parses a JSON string, constructing the JavaScript value or object described by the string.
JSON.stringify()
Converts a JavaScript value to a JSON string.
JSON.stringify() with replacer
Uses a replacer function to filter or transform values during JSON stringification.
JSON.parse() with reviver
Uses a reviver function to transform values during JSON parsing.
toJSON()
A method that can be defined on an object to customize its JSON serialization.
⏳ Promise (10)
then()
Attaches callbacks for the resolution and/or rejection of the Promise.
catch()
Attaches a rejection handler callback to the promise.
finally()
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected).
Promise.resolve()
Returns a Promise object that is resolved with the given value.
Promise.reject()
Returns a Promise object that is rejected with the given reason.
Promise.all()
Returns a single Promise that resolves when all of the promises in the iterable have resolved, or rejects when any promise rejects.
Promise.allSettled()
Returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects describing each outcome.
Promise.race()
Returns a promise that fulfills or rejects as soon as one of the promises fulfills or rejects.
Promise.any()
Returns a promise that fulfills when any of the promises fulfills, or rejects if all of the promises reject.
new Promise()
Creates a new Promise object with an executor function that receives resolve and reject callbacks.