Reference
Reference
Alphabetical list of 166 JavaScript items with descriptions.
❓ FAQ
QHow many entries does the JavaScript reference cover?
AIt covers 167 entries across arrays, strings, DOM, Math, dates, async, objects, statements and operators. Every entry includes syntax, parameters, return values and a runnable example.
QCan I run the examples directly in the browser?
AYes. Entries with examples embed a browser editor: edit the snippet and press Run. All examples are plain JavaScript and do not need Node.js.
QWhat is the difference between method, statement, operator and object entries?
AMethod entries explain how to call a function such as Array.map; statement entries explain syntax such as if and for; operator entries explain how symbols evaluate; object entries cover built-ins such as Date and JSON. Pick the category that matches your question.
QHow do I use array reduce in JavaScript?
Areduce folds an array into one value: array.reduce((acc, cur) => acc + cur, 0). The second argument is the initial value; omit it and the first element is used, while an empty array throws.
QWhat is the difference between shift and unshift?
Ashift removes and returns the first element; unshift adds elements at the start and returns the new length. Both mutate the original array and are slow on very large arrays.
QWhat does document.getElementById return?
AIt returns the first element with the matching id, or null if none exists. Check for null before using the result.
QWhat is the difference between let, const and var?
Alet is reassignable and block-scoped; const cannot be rebound and is also block-scoped; var is function-scoped and hoisted. Prefer const, then let, and avoid var in modern code.
QHow do I add an event listener in JavaScript?
AUse element.addEventListener('click', handler) instead of onclick so you do not overwrite existing handlers. Keep the same function reference when calling removeEventListener.