Reference

Last updated: 2026-09-09

Reference

Alphabetical list of 160 JavaScript items with descriptions.

#
= += -= 等赋值运算符Assignment operators store values in variables. Compound assignments combine an operation ...
&& || ! ??Logical operators combine conditions. && short-circuits, || short-circuits, ! negates, ?? ...
? : 三元运算符The ternary is the expression version of if...else: condition ? valueIfTrue : valueIfFalse...
... 展开运算符The spread operator ... expands an iterable into individual elements.
?. 可选链Optional chaining ?. safely accesses nested properties — returns undefined instead of thro...
模板字符串Template literals use backticks with ${} for interpolation and multi-line support.
常用事件类型DOM event types: mouse, keyboard, form, touch events.
A
ArrayArray is JavaScript's built-in array object: a constructor for ordered lists with 30+ meth...
Array.concat()concat returns a brand-new array with the given values appended; arrays are flattened one ...
Array.filter()filter calls the callback once per element and returns a new array of the elements for whi...
Array.find()find returns the first element satisfying the test, or undefined. Use some for existence c...
Array.findIndex()findIndex returns the index of the first element satisfying the test, or -1. Commonly pair...
Array.forEach()forEach runs the callback once per element in order, returns undefined, and cannot be brok...
Array.includes()includes reports whether the array contains a value, returning true or false. Clearer than...
Array.indexOf()indexOf returns the index of the first occurrence, or -1. It compares strictly and cannot ...
Array.join()join concatenates all elements into a string with a separator; undefined and null become e...
Array.map()map runs the callback per element and builds a new array of the same length from the resul...
Array.pop()pop removes the last element and returns it; an empty array returns undefined without thro...
Array.push()push appends one or more elements to the end and returns the new length. Together with pop...
Array.reduce()reduce folds the array into a single value by accumulating callback results — sums, counts...
Array.reverse()reverse reverses the array in place and returns the same reference. Copy first to keep the...
Array.shift()shift removes the first element and returns it; an empty array returns undefined. With uns...
Array.slice()slice extracts a shallow-copied section (start inclusive, end exclusive) with negative ind...
Array.some()some reports whether at least one element passes the test, returning a boolean; it stops a...
Array.sort()Default sort converts to strings — 10 comes before 9! Pass a comparator for numbers.
Array.splice()splice removes items at an index and optionally inserts new ones, returning the removed it...
Array.unshift()unshift prepends elements and returns the new length. O(n) — every element shifts right.
Array.isArray()Array.isArray is the standard check — typeof returns object for arrays and instanceof fail...
async/awaitasync/await is syntactic sugar for Promises, making async code look synchronous.
B
BooleanBoolean provides type checking.
C
constconst declares a block-scoped constant: it must be initialized immediately and the name ca...
ConsoleConsole provides debugging output methods.
classclass is a template for creating objects with a constructor, methods and getters/setters.
Comparison operatorsComparison operators return booleans. === (strict) is preferred; == (loose) should be avoi...
console.log()console.log outputs to the browser console. Supports multiple arguments.
console.error()console.error outputs an error message (red) to the console.
console.table()console.table displays array or object data as a table.
D
DateDate is the built-in date object.
DocumentDocument is the root DOM object.
Date.getFullYear()getFullYear returns the 4-digit year of a Date object.
Date.getMonth()getMonth returns the month (0-11) — 0 is January. The most common JS date pitfall!
Date.getDate()getDate returns the day of the month (1-31). Don't confuse with getDay (day of week).
Date.getDay()getDay returns the day of the week (0-6), 0 = Sunday. Not the same as getDate.
Date.getHours()getHours returns the hour (0-23), 24-hour format.
Date.now()Date.now returns milliseconds since Unix epoch — the simplest timestamp method.
Date.toISOString()toISOString returns an ISO 8601 string (YYYY-MM-DDTHH:mm:ss.sssZ) always in UTC.
Date.parse()Date.parse parses a date string and returns milliseconds since epoch.
delete 运算符delete removes a property from an object. Returns true. Not recommended for arrays — use s...
decodeURIComponent()decodeURIComponent decodes a string encoded by encodeURIComponent.
document.getElementById()getElementById gets a single element by its id attribute.
document.querySelector()querySelector gets the first element matching a CSS selector.
document.querySelectorAll()querySelectorAll returns a NodeList of all matching elements.
document.createElement()createElement creates a new DOM element (not yet in the page).
E
ErrorError is the base class with name/message/stack. Built-in subtypes included.
ElementElement is the base class for DOM element objects.
EventsThe DOM event model with bubbling and delegation.
encodeURIComponent()encodeURIComponent encodes URI components — the standard for building query parameters.
element.innerHTMLinnerHTML gets or sets the HTML content of an element.
element.textContenttextContent gets or sets the plain text content — safer and faster than innerHTML.
element.classListclassList provides add/remove/toggle/contains for CSS classes.
element.setAttribute()setAttribute sets an HTML attribute on an element.
element.getAttribute()getAttribute returns the value of an HTML attribute, or null.
Element.removeAttribute()removeAttribute removes an HTML attribute from the element.
element.stylestyle reads/writes inline CSS styles using camelCase property names.
element.valuevalue gets or sets the current value of form elements.
element.appendChild()appendChild adds a node as the last child. If the node already exists it is moved.
element.remove()remove removes the element from the DOM. Simpler than parentNode.removeChild(el).
element.addEventListener()addEventListener attaches an event handler — the standard way to handle DOM events.
element.removeEventListener()removeEventListener removes a listener — must pass the exact same function reference.
event 事件对象The event object contains all event info: target, type, coordinates.
element.insertAdjacentHTML()insertAdjacentHTML inserts HTML at a specified position without overwriting existing conte...
F
FunctionFunction is the constructor for functions. Functions are first-class citizens.
forA for loop has init, condition and update parts — ideal for counted iteration.
for...offor...of iterates over iterable objects (arrays, strings, Map, Set). Not for plain objects...
functionfunction declares a reusable callable. Functions are first-class citizens in JS.
I
if...elseif...else executes different code blocks based on a condition.
instanceofinstanceof checks whether an object is an instance of a constructor.
in 运算符in checks whether a property exists on an object (including the prototype chain).
J
JSONJSON provides parse and stringify.
JSON.parse()JSON.parse converts a JSON string into a JS value. The standard way to handle API response...
JSON.stringify()JSON.stringify converts a JS value into a JSON string — the standard way to send data to A...
L
letlet declares a block-scoped variable: it only exists inside the nearest pair of curly brac...
LocationLocation provides URL info and navigation methods.
location.hreflocation.href gets or sets the current page URL. Setting it navigates.
location.reload()reload reloads the current page. Pass true to force a server reload.
localStorage.setItem()setItem stores a key-value pair in localStorage. Values must be strings — use JSON.stringi...
localStorage.getItem()getItem reads a value from localStorage by key. Returns null if the key doesn't exist.
localStorage.removeItem()removeItem deletes a key-value pair from localStorage. Safe for missing keys.
M
MathMath is a math utility set with static methods.
MapMap is a key-value collection with any-type keys. Maintains insertion order.
Math.abs()Math.abs returns the absolute value.
Math.ceil()Math.ceil rounds up to the smallest integer >= the given number.
Math.floor()Math.floor rounds down to the largest integer <= the given number.
Math.round()Math.round rounds to the nearest integer; .5 rounds up.
Math.max()Math.max returns the largest of the given numbers.
Math.min()Math.min returns the smallest of the given numbers.
Math.random()Math.random returns a pseudo-random decimal in [0, 1).
Math.pow()Math.pow returns base to the power of exponent. Equivalent to the ** operator.
Math.trunc()Math.trunc removes the fractional part (truncates toward zero).
N
NumberNumber is JavaScript's built-in number object providing formatting, type checks and safe r...
NodeListNodeList is a collection from querySelectorAll. Has forEach, not an array.
Number.toFixed()toFixed formats a number with fixed decimal places, returning a string.
Number.toString()toString converts a number to a string, optionally in a different base.
Number.isInteger()Number.isInteger checks whether a value is an integer.
Number.toPrecision()toPrecision formats a number to a specified number of significant digits.
Number.MAX_SAFE_INTEGERMAX_SAFE_INTEGER is the largest integer JS can represent exactly (2^53 - 1).
Number.isNaN()Number.isNaN checks whether a value is NaN. NaN is the only value not equal to itself.
Number.isFinite()Number.isFinite checks whether a value is a finite number.
O
ObjectObject is the base class with static methods.
Object.keys()Object.keys returns an array of the object's enumerable property names.
Object.values()Object.values returns an array of the object's enumerable property values.
Object.entries()Object.entries returns [key, value] pairs — the most elegant way to iterate an object.
Object.assign()Object.assign copies enumerable properties from source objects to the target — a shallow m...
Object.freeze()Object.freeze makes an object immutable: no add, delete or modify. Shallow freeze only.
Object.hasOwn()Object.hasOwn checks whether an object has the specified own property — a safer hasOwnProp...
P
PromisePromise is the core async object. Three states: pending/fulfilled/rejected.
Promise.then()then registers a fulfillment callback and returns a new Promise for chaining.
Promise.catch()catch registers a rejection callback. Syntactic sugar for then(undefined, onRejected).
Promise.finally()finally registers a callback that runs when the Promise settles (either way).
Promise.all()Promise.all waits for all Promises to fulfill; rejects immediately on any failure.
Promise.race()Promise.race returns the first Promise to settle (fulfilled or rejected).
Promise.allSettled()Promise.allSettled waits for all Promises to settle and returns status for each.
parseInt()parseInt parses a string and returns an integer, ignoring leading whitespace.
parseFloat()parseFloat parses a string and returns a floating-point number.
parentNode / parentElementparentNode returns the parent node; parentElement returns the parent element only.
R
RegExpRegExp is the regular expression object for pattern matching.
returnreturn terminates the function and returns a value; without it the function returns undefi...
S
StringString is JavaScript's built-in string object with 30+ methods for searching, slicing, rep...
SetSet is a collection of unique values — the standard dedup method.
SymbolSymbol is an ES6 primitive creating unique identifiers for object keys.
StorageStorage represents the Web Storage API.
String.charAt()charAt returns the UTF-16 code unit at the given zero-based index, or an empty string when...
String.includes()includes checks whether the string contains the given substring, returning true or false.
String.indexOf()indexOf returns the index of the first occurrence, or -1. Case-sensitive.
String.replace()replace swaps matched text; a string pattern replaces only the first match, a regex with g...
String.replaceAll()replaceAll replaces ALL matched substrings and returns a new string — clearer than regex w...
String.slice()slice extracts a substring with negative index support; the original is untouched.
String.split()split breaks the string into an array around a separator — the inverse of join.
String.substring()substring extracts between indices, swapping out-of-order args; prefer slice in new code.
String.toLowerCase()toLowerCase returns a new lowercased string. The standard method for case-insensitive comp...
String.toUpperCase()toUpperCase returns a new uppercased string. Used for title formatting, constant generatio...
String.trim()trim strips leading and trailing whitespace — typical for cleaning user input.
String.startsWith()startsWith checks if the string starts with the given prefix.
String.endsWith()endsWith checks if the string ends with the given suffix.
String.padStart()padStart pads the start to a target length — the classic zero-padding trick.
String.repeat()repeat returns the string repeated count times.
String.match()match extracts regex matches; with g flag returns all matches as an array.
String.charCodeAt()charCodeAt returns the UTF-16 code unit at the given index.
String.concat()concat joins strings into a new one; the + operator or template literals are more common.
switchswitch matches an expression against case branches. Don't forget break!
setTimeout()setTimeout runs a callback after the specified milliseconds. Returns a timer ID for clearT...
T
typeoftypeof returns a string naming the type of its operand — the quickest way to inspect a val...
try...catchtry...catch catches runtime errors; finally runs regardless.
V
varvar was the only way to declare variables before ES6. It is function-scoped rather than bl...
W
WindowWindow is the browser global object.
whilewhile repeats while the condition is true — for unknown iteration counts.
window.alert()alert shows a modal dialog with a message and OK button. Blocks execution.
window.confirm()confirm shows a dialog with OK/Cancel and returns a boolean.
window.prompt()prompt shows a dialog with an input field, returning the entered string or null.
window.open()window.open opens a new browser window/tab. May be blocked by popup blockers.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏