You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides a comprehensive overview of commonly used JavaScript methods, grouped by their functionality, along with brief descriptions and usage examples.
Document Object Model (DOM) Manipulation
JavaScript Method
Description
Example
document.querySelector
Selects the first element that matches a CSS selector
Creates an array from an array-like or iterable object
Array.from(document.querySelectorAll('div'))
Array.isArray
Checks if a value is an array
Array.isArray([1, 2, 3])
Array.prototype.map
Creates a new array with the results of a function
array.map(x => x * 2)
Array.prototype.filter
Creates a new array with all elements that pass a test
array.filter(x => x > 10)
Array.prototype.forEach
Executes a function once for each array element
array.forEach(x => console.log(x))
Array.prototype.reduce
Reduces array to a single value using a function
array.reduce((acc, cur) => acc + cur, 0)
Array.prototype.push
Adds elements to the end of an array
array.push(4)
Array.prototype.pop
Removes the last element from an array
array.pop()
Array.prototype.shift
Removes the first element from an array
array.shift()
Array.prototype.unshift
Adds elements to the beginning of an array
array.unshift(0)
Array.prototype.slice
Returns a portion of an array as a new array
array.slice(1, 3)
Array.prototype.splice
Changes array by removing/replacing elements
array.splice(1, 1, 'newElement')
Array.prototype.concat
Merges arrays
array1.concat(array2)
Array.prototype.join
Joins array elements into a string
array.join(', ')
Array.prototype.indexOf
Finds the first index of a value
array.indexOf('element')
Array.prototype.find
Finds the first element that passes a test
array.find(el => el > 10)
Array.prototype.findIndex
Finds the index of the first element that passes a test
array.findIndex(el => el > 10)
String Methods
JavaScript Method
Description
Example
String.prototype.charAt
Returns the character at a specified index
'string'.charAt(0)
String.prototype.charCodeAt
Returns the Unicode of the character at a specified index
'string'.charCodeAt(0)
String.prototype.concat
Joins two or more strings
'Hello'.concat(' ', 'World')
String.prototype.includes
Checks if a string contains another string
'Hello World'.includes('World')
String.prototype.indexOf
Finds the first index of a value
'Hello World'.indexOf('World')
String.prototype.lastIndexOf
Finds the last index of a value
'Hello World'.lastIndexOf('o')
String.prototype.match
Matches a string against a regex
'Hello World'.match(/o/g)
String.prototype.replace
Replaces matches of a string with a new string
'Hello World'.replace('World', 'Everyone')
String.prototype.search
Searches a string for a match
'Hello World'.search('World')
String.prototype.slice
Extracts a part of a string
'Hello World'.slice(0, 5)
String.prototype.split
Splits a string into an array
'Hello World'.split(' ')
String.prototype.substring
Extracts characters from a string
'Hello World'.substring(0, 5)
String.prototype.toLowerCase
Converts a string to lower case
'Hello World'.toLowerCase()
String.prototype.toUpperCase
Converts a string to upper case
'Hello World'.toUpperCase()
String.prototype.trim
Trims whitespace from both ends of a string
' Hello World '.trim()
This document provides a quick reference to commonly used JavaScript methods. For more detailed information, refer to the MDN Web Docs.
About
This repository provides a comprehensive overview of commonly used JavaScript methods, grouped by their functionality, along with brief descriptions and usage examples.