WeCodeAcademy

JavaScript Reference

Built-in JavaScript methods and functions: strings, arrays, numbers, Math, objects, JSON and more.

86 of 86
NameGroupDescription
String.lengthStringThe number of characters in a string.
toUpperCase()StringReturns the string in upper case.
toLowerCase()StringReturns the string in lower case.
trim()StringRemoves whitespace from both ends.
slice()StringExtracts part of a string.
substring()StringExtracts characters between two indexes.
indexOf()StringThe position of the first match, or -1.
includes()StringWhether a string contains text.
startsWith()StringWhether a string starts with text.
endsWith()StringWhether a string ends with text.
replace()StringReplaces the first match.
replaceAll()StringReplaces every match.
split()StringSplits a string into an array.
repeat()StringRepeats a string.
padStart()StringPads the start to a length.
padEnd()StringPads the end to a length.
charAt()StringThe character at an index.
at()StringThe character at an index; negative counts from the end.
concat()StringJoins strings.
match()StringFinds matches with a regular expression.
localeCompare()StringCompares strings for sorting.
Array.lengthArrayThe number of items in an array.
push()ArrayAdds items to the end.
pop()ArrayRemoves and returns the last item.
shift()ArrayRemoves and returns the first item.
unshift()ArrayAdds items to the start.
slice()ArrayCopies part of an array.
splice()ArrayAdds or removes items in place.
concat()ArrayJoins arrays.
join()ArrayJoins items into a string.
reverse()ArrayReverses an array in place.
sort()ArraySorts an array in place.
indexOf()ArrayThe first index of an item, or -1.
includes()ArrayWhether an array contains an item.
find()ArrayThe first item that passes a test.
findIndex()ArrayThe index of the first item that passes a test.
filter()ArrayA new array of items that pass a test.
map()ArrayA new array made by transforming each item.
reduce()ArrayCombines all items into one value.
forEach()ArrayRuns a function for each item.
some()ArrayWhether any item passes a test.
every()ArrayWhether every item passes a test.
flat()ArrayFlattens nested arrays.
flatMap()ArrayMaps then flattens one level.
fill()ArrayFills an array with a value.
Array.isArray()ArrayWhether a value is an array.
Array.from()ArrayMakes an array from an iterable.
at()ArrayThe item at an index; negative counts from the end.
Number()NumberConverts a value to a number.
parseInt()NumberParses an integer from a string.
parseFloat()NumberParses a decimal from a string.
toFixed()NumberFormats a number with fixed decimals.
Number.isInteger()NumberWhether a value is an integer.
isNaN()NumberWhether a value is NaN.
Math.round()MathRounds to the nearest integer.
Math.floor()MathRounds down.
Math.ceil()MathRounds up.
Math.trunc()MathRemoves the decimal part.
Math.abs()MathThe absolute value.
Math.max()MathThe largest of the arguments.
Math.min()MathThe smallest of the arguments.
Math.pow()MathRaises to a power.
Math.sqrt()MathThe square root.
Math.random()MathA random number from 0 up to (not including) 1.
Math.PIMathThe value of pi.
Object.keys()ObjectAn array of an object's property names.
Object.values()ObjectAn array of an object's values.
Object.entries()ObjectAn array of [key, value] pairs.
Object.assign()ObjectCopies properties into an object.
Object.freeze()ObjectMakes an object read only.
hasOwnProperty()ObjectWhether an object has its own property.
JSON.stringify()JSONConverts a value to JSON text.
JSON.parse()JSONConverts JSON text to a value.
console.log()ConsolePrints values to the console.
setTimeout()TimersRuns a function once after a delay.
setInterval()TimersRuns a function repeatedly.
PromiseAsyncAn object for a value that arrives later.
async / awaitAsyncWrite asynchronous code that reads in order.
DateDateWorks with dates and times.
Date.now()DateMilliseconds since 1 January 1970.
typeofOperatorsThe type of a value.
SetCollectionsA collection of unique values.
MapCollectionsA collection of key-value pairs.
RegExp.test()RegExpTests a string against a pattern.
structuredClone()GlobalMakes a deep copy of a value.
encodeURIComponent()GlobalEncodes text for use in a URL.