๐ŸŸจ JavaScript Dictionary

Every keyword, operator, and symbol โ€” with plain-English explanations.

!== operator
Strict inequality: true when value or type differ.
if (a !== b) {}
... operator
Spread/rest: expands an iterable into individual items, or gathers into array.
const copy = [...arr]; function f(...args) {}
?. operator
Optional chaining: safely reads a property without throwing if left side is null.
user?.address?.city
?? operator
Nullish coalescing: returns right side only if left is null or undefined.
const name = user.name ?? 'Guest'
Array.every method
Returns true if all elements pass the test.
arr.every(x => x > 0)
Array.filter method
Creates a new array with only elements that pass the test function.
[1,2,3,4].filter(x => x % 2 === 0) // [2,4]
Array.find method
Returns the first element that passes the test, or undefined.
users.find(u => u.id === 5)
Array.flat method
Flattens nested arrays by the given depth (default 1).
[[1,2],[3]].flat() // [1,2,3]
Array.forEach method
Calls a function for each element โ€” no return value.
arr.forEach(x => console.log(x))
Array.from method
Creates an array from an iterable or array-like object.
Array.from('hello') // ['h','e','l','l','o']
Array.includes method
Returns true if the array contains the given value.
[1,2,3].includes(2) // true
Array.join method
Joins all elements into a string with the given separator.
arr.join(', ')
Array.map method
Creates a new array by applying a function to each element.
[1,2,3].map(x => x * 2) // [2,4,6]
Array.pop method
Removes and returns the last element of an array.
const last = arr.pop()
Array.push method
Adds one or more elements to the end of an array and returns new length.
arr.push(4)
Array.reduce method
Reduces an array to a single value by applying a function to each element.
[1,2,3].reduce((acc, x) => acc + x, 0) // 6
Array.shift method
Removes and returns the first element of an array.
const first = arr.shift()
Array.slice method
Returns a shallow copy of a portion of the array without modifying original.
arr.slice(1, 3)
Array.some method
Returns true if at least one element passes the test.
arr.some(x => x > 10)
Array.sort method
Sorts the array in place. Pass a comparator for numeric sort.
arr.sort((a, b) => a - b)
Array.splice method
Inserts, removes, or replaces elements in place at a given index.
arr.splice(2, 1, 'new')
Array.unshift method
Adds elements to the beginning of an array.
arr.unshift(0)
JSON.stringify global
Converts a JavaScript value to a JSON string.
JSON.stringify({a:1}) // '{"a":1}'
Object.assign method
Copies properties from source objects into a target object.
Object.assign(target, source)
Object.entries method
Returns an array of [key, value] pairs for own enumerable properties.
Object.entries(obj).forEach(([k,v]) => {})
Object.freeze method
Makes an object immutable โ€” no properties can be added, removed, or changed.
const o = Object.freeze({x:1})
Object.keys method
Returns an array of an object's own enumerable property names.
Object.keys({a:1, b:2}) // ['a','b']
Object.values method
Returns an array of an object's own enumerable property values.
Object.values({a:1, b:2}) // [1,2]
Promise.all method
Resolves when all promises resolve, or rejects when any rejects.
const results = await Promise.all([p1, p2])
Promise.race method
Settles as soon as the first promise in the array settles.
const first = await Promise.race([p1, p2])
String.endsWith method
Returns true if the string ends with the given suffix.
'file.js'.endsWith('.js')
String.includes method
Returns true if the string contains the given substring.
'hello world'.includes('world')
String.padStart method
Pads the start of a string to reach a target length.
'5'.padStart(3, '0') // '005'
String.replace method
Replaces the first match of a pattern with a replacement string.
'hello'.replace('l', 'r') // 'herlo'
String.slice method
Extracts part of a string, returning a new string.
'hello'.slice(1, 3) // 'el'
String.split method
Splits a string into an array of substrings using a separator.
'a,b,c'.split(',') // ['a','b','c']
String.startsWith method
Returns true if the string begins with the given prefix.
'https://'.startsWith('https')
String.toLowerCase method
Returns the string converted to all lowercase.
'HELLO'.toLowerCase() // 'hello'
String.toUpperCase method
Returns the string converted to all uppercase.
'hello'.toUpperCase() // 'HELLO'
String.trim method
Removes leading and trailing whitespace from a string.
'  hi  '.trim() // 'hi'
addEventListener DOM
Attaches an event handler to an element for a specified event type.
btn.addEventListener('click', handler)
async keyword
Marks a function as asynchronous โ€” it always returns a Promise.
async function fetchData() { }
at JAVASCRIPT ARRAY METHODS
Returns the value of the element at the specified index or undefined if the index is out of range.
[].at(0)
await keyword
Pauses an async function until a Promise resolves, then returns its value.
const data = await fetch(url).then(r => r.json())
break keyword
Exits the nearest enclosing loop or switch statement.
for (...) { if (done) break }
case keyword
A branch label inside a switch statement.
case 'error': handleError(); break
catch keyword
Handles errors thrown in the corresponding try block.
catch (e) { console.error(e.message) }
class keyword
Defines an ES6 class with constructor, methods, and optional inheritance.
class Animal { constructor(name) { this.name = name } }
classList DOM
Provides methods to add, remove, toggle, and check CSS classes.
el.classList.add('active')
clearInterval global
Cancels an interval created by setInterval.
clearInterval(id)
clearTimeout global
Cancels a timeout created by setTimeout.
clearTimeout(id)
console.error global
Prints an error message to the console (shown in red in browsers).
console.error('failed:', err)
console.table global
Displays an array or object as a formatted table in the console.
console.table(users)
console.warn global
Prints a warning message to the console.
console.warn('deprecated function')
continue keyword
Skips the rest of the current loop iteration.
for (...) { if (skip) continue }
default keyword
The fallback branch of a switch when no case matches.
default: console.log('unknown')
delete operator
Removes a property from an object.
delete obj.key
do keyword
Runs a loop body at least once, then repeats while the condition is true.
do { x++ } while (x < 10)
document.getElementById DOM
Returns the element with the given id, or null if not found.
const btn = document.getElementById('submit')
document.querySelector DOM
Returns the first element matching a CSS selector.
const el = document.querySelector('.active')
document.querySelectorAll DOM
Returns all elements matching a CSS selector as a NodeList.
document.querySelectorAll('li').forEach(el => {})
else keyword
The branch that runs when an if condition is false.
if (x) {} else { doDefault() }
export keyword
Makes a binding available to other modules.
export function add(a, b) { return a + b }
extends keyword
Creates a subclass that inherits from a parent class.
class Dog extends Animal { bark() { } }
finally keyword
Runs cleanup code after try/catch regardless of whether an error occurred.
finally { cleanup() }
for keyword
Classic counted loop: initializer; condition; increment.
for (let i = 0; i < 10; i++) {}
if keyword
Executes a block when its condition is true.
if (x > 0) { console.log('positive') }
import keyword
Imports bindings from another ES module.
import { add } from './math.js'
in operator
Returns true if a property name exists in an object.
'length' in []
includes JAVASCRIPT ARRAY METHODS
Returns a boolean indicating whether the array includes a certain value.
[1, 2, 3].includes(2)
indexOf JAVASCRIPT ARRAY METHODS
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
[1, 2, 3].indexOf(2)
innerHTML DOM
Gets or sets the HTML content inside an element.
el.innerHTML = '<b>updated</b>'
instanceof operator
Checks whether an object was created by a given constructor.
if (err instanceof TypeError) { }
isArray JAVASCRIPT ARRAY METHODS
Returns true if the specified value is an Array.
Array.isArray([1, 2, 3])
join JAVASCRIPT ARRAY METHODS
Joins all elements of an array into a string.
[1, 2, 3].join(',')
keys JAVASCRIPT ARRAY METHODS
Returns an ArrayIterator object that contains the keys (indices) of each index in the array.
[1, 2, 3].keys().next().value$,
lastIndexOf JAVASCRIPT ARRAY METHODS
Returns the index of the last occurrence of a specified value in an array.
[1, 2, 3, 2, 1].lastIndexOf(2)
length JAVASCRIPT ARRAY METHODS
Returns the number of elements in an array.
[1, 2, 3].length$,
map JAVASCRIPT ARRAY METHODS
Creates a new array with the results of calling a provided function on every element in the calling array.
[1, 2, 3].map(x => x * 2)
new keyword
Creates an instance of a class or constructor function.
const dog = new Dog('Rex')
return keyword
Exits a function, optionally returning a value to the caller.
return result
setInterval global
Calls a function repeatedly at a fixed interval in milliseconds.
const id = setInterval(tick, 500)
setTimeout global
Calls a function once after a specified delay in milliseconds.
setTimeout(() => doWork(), 1000)
switch keyword
Compares a value against multiple cases and runs the matching branch.
switch(day) { case 'Mon': work(); break }
template literal syntax
String delimited by backticks allowing embedded expressions with ${} syntax.
const msg = `Hello, ${name}!`
textContent DOM
Gets or sets the plain text content of an element (no HTML parsing).
el.textContent = 'Hello'
this keyword
Refers to the current execution context โ€” the object the method was called on.
this.name = name
throw keyword
Throws an exception, transferring control to the nearest catch block.
throw new Error('invalid input')
try keyword
Wraps code that might throw an error. Paired with catch and/or finally.
try { riskyOp() } catch (e) { handle(e) }
typeof operator
Returns a string describing the type of its operand.
typeof 42 // 'number'
var keyword
Declares a function-scoped variable. Prefer let or const in modern JS.
var x = 5
void operator
Evaluates an expression and returns undefined.
void someCall()
while keyword
Loops as long as a condition remains true.
while (queue.length > 0) { process(queue.shift()) }
concat JAVASCRIPT ARRAY METHODS
Concatenates two or more arrays and returns a new array.
[1, 2].concat([3, 4])
let keyword
Block-scoped variable that can be reassigned.
let x = 5;
const keyword
Block-scoped constant that cannot be reassigned.
const PI = 3.14;
copyWithin JAVASCRIPT ARRAY METHODS
Copies a portion of an array to another location in the same array and returns the modified array.
[1, 2, 3, 4, 5].copyWithin(0, 3, 5)
entries JAVASCRIPT ARRAY METHODS
Returns a new Array Iterator object that contains the key-value pairs for each index in the array.
[1, 2, 3].entries().next().value$,
function keyword
Declares a named function.
function greet(name) { return name; }
=> operator
Arrow function โ€” shorter syntax, no own this binding.
const add = (a, b) => a + b;
every JAVASCRIPT ARRAY METHODS
Tests whether all elements in the array pass the test implemented by the provided function.
[1, 2, 3].every(num => num > 0)
async/await keyword
Marks function async; await pauses until Promise resolves.
const data = await fetch(url);
fill JAVASCRIPT ARRAY METHODS
Fills the elements of an array with a static value, from a start index (inclusively) to an end index (exclusively).
[1, 2, 3, 4, 5].fill(0, 1, 4)
=== operator
Strict equality โ€” checks value AND type.
5 === 5
filter JAVASCRIPT ARRAY METHODS
Returns a new array with all elements that pass the test implemented by the provided function.
[1, 2, 3, 4, 5].filter(num => num % 2 === 0)
console.log function
Prints to browser or Node.js console.
console.log(x);
find JAVASCRIPT ARRAY METHODS
Returns the value of the first element in the array that passes the test implemented by the provided function.
[1, 2, 3, 4, 5].find(num => num > 2)
fetch function
Makes HTTP request, returns Promise.
const res = await fetch("/api");
findIndex JAVASCRIPT ARRAY METHODS
Returns the index of the first element in the array that passes the test implemented by the provided function, or -1 if no such element is found.
[1, 2, 3, 4, 5].findIndex(num => num > 2)
JSON.parse function
Parses JSON string to JS object.
const obj = JSON.parse(str);
findLast JAVASCRIPT ARRAY METHODS
Returns the value of the last element in the array that passes the test implemented by the provided function.
[1, 2, 3, 4, 5].findLast(num => num > 2)
Promise class
Represents eventual completion of async operation.
new Promise((res, rej) => {})
findLastIndex JAVASCRIPT ARRAY METHODS
Returns the index of the last element in the array that passes the test implemented by the provided function, or -1 if no such element is found.
[1, 2, 3, 4, 5].findLastIndex(num => num > 2)
flat JAVASCRIPT ARRAY METHODS
Flattens an array by the specified depth.
[[1, 2], [3, 4]].flat(2)
flatMap JAVASCRIPT ARRAY METHODS
Mutates an array by applying a function to each of its elements and flattening the result into a new array.
[1, 2, 3, 4, 5].flatMap(num => [num, num * 2])
forEach JAVASCRIPT ARRAY METHODS
Invokes a provided function once for each array element.
[1, 2, 3, 4, 5].forEach(num => console.log(num))
from JAVASCRIPT ARRAY METHODS
Creates an array from an array-like or iterable object.
Array.from('Hello')
fromAsync JAVASCRIPT ARRAY METHODS
Creates an array from an iterable object or a function that asynchronously returns an iterable object.
Array.fromAsync(asyncIterable)