SyntaxStudy
Sign Up
Home JavaScript Reference

JavaScript Reference

33 entries — click any item for full details and examples

Array Methods

Name Description
map() ES5 Creates a new array populated with the results of calling a function on every element.
filter() ES5 Creates a new array with all elements that pass the test implemented by the provided function.
reduce() ES5 Executes a reducer function on each element, resulting in a single output value.
forEach() ES5 Executes a provided function once for each array element. Does not return a value.
find() / findIndex() ES6 find() returns the first element satisfying the test; findIndex() returns its index.
some() / every() ES5 some() returns true if at least one element passes; every() returns true if all pass.
flat() / flatMap() ES2019 flat() flattens nested arrays; flatMap() maps then flattens one level.
splice() / slice() splice() modifies array in place (add/remove). slice() returns a shallow copy of a portion.
sort() Sorts an array in place. Without a comparator, sorts as strings. Provide a comparator for numbers.
includes() / indexOf() ES6 includes() checks if an element exists (returns boolean); indexOf() returns its position.

String Methods

Name Description
split() Splits a string into an array of substrings based on a separator.
replace() / replaceAll() ES2021 replace() replaces the first match; replaceAll() replaces all occurrences.
includes() / startsWith() / endsWith() ES6 Check whether a string contains, begins with, or ends with a given substring.
trim() / trimStart() / trimEnd() ES2019 Removes whitespace from both ends, just the beginning, or just the end of a string.
padStart() / padEnd() ES2017 Pads the current string with another string until it reaches a specified length.
Template Literals ES6 Template literals allow embedded expressions, multi-line strings, and tagged templates.

Object Methods

Name Description
Object.keys() / values() / entries() ES6 Return arrays of an object's own enumerable property keys, values, or key-value pairs.
Object.assign() ES6 Copies all enumerable own properties from source objects to a target object. Returns the target.
Destructuring ES6 Extracts values from arrays or properties from objects into distinct variables.
Spread / Rest operator ES6 Spread expands iterables in places expecting multiple elements. Rest collects remaining arguments.
Promise / async-await ES6 Promises represent eventual completion of async operations. async/await is syntactic sugar over Promises.

Math Methods

Name Description
Math.round() / floor() / ceil() round() rounds to nearest integer; floor() rounds down; ceil() rounds up.
Math.random() Returns a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive).
Math.max() / Math.min() Returns the largest or smallest of zero or more numbers.

DOM Methods

Name Description
querySelector() / querySelectorAll() Select DOM elements using CSS selector syntax. querySelector returns one; querySelectorAll returns a NodeList.
addEventListener() Attaches an event handler to an element. Preferred over inline handlers.
classList Provides methods to add, remove, toggle, and check CSS classes on an element.
createElement() / appendChild() / innerHTML Create new DOM elements, set their content, and insert them into the document.
fetch() ES6 Makes HTTP requests and returns a Promise that resolves to a Response object.

Window/Browser APIs

Name Description
localStorage / sessionStorage Web Storage APIs for storing data in the browser. localStorage persists; sessionStorage is per-tab.
setTimeout() / setInterval() setTimeout delays function execution once; setInterval repeats it at specified intervals.
JSON.parse() / JSON.stringify() Convert between JSON strings and JavaScript values. stringify serializes; parse deserializes.
console methods The console object provides access to the browser debugging console.