JavaScript Guide - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide • 206 KB fetched Open original page
JavaScript Guide - JavaScript | MDN
*
Skip to main content
*
Skip to search
HTML
HTML: Markup language
HTML reference
*
Elements
*
Global attributes
*
Attributes
*
See all…
HTML guides
*
Responsive images
*
HTML cheatsheet
*
Date & time formats
*
See all…
Markup languages
*
SVG
*
MathML
*
XML
CSS
CSS: Styling language
CSS reference
*
Properties
*
Selectors
*
At-rules
*
Values
*
See all…
CSS guides
*
Box model
*
Animations
*
Flexbox
*
Colors
*
See all…
Layout cookbook
*
Column layouts
*
Centering an element
*
Card component
*
See all…
JavaScript JS
JavaScript: Scripting language
JS reference
*
Standard built-in objects
*
Expressions & operators
*
Statements & declarations
*
Functions
*
See all…
JS guides
*
Control flow & error handing
*
Loops and iteration
*
Working with objects
*
Using classes
*
See all…
Web APIs
Web APIs: Programming interfaces
Web API reference
*
File system API
*
Fetch API
*
Geolocation API
*
HTML DOM API
*
Push API
*
Service worker API
*
See all…
Web API guides
*
Using the Web animation API
*
Using the Fetch API
*
Working with the History API
*
Using the Web speech API
*
Using web workers
All
All web technology
Technologies
*
Accessibility
*
HTTP
*
URI
*
Web extensions
*
WebAssembly
*
WebDriver
*
See all…
Topics
*
Media
*
Performance
*
Privacy
*
Security
*
Progressive web apps
Learn
Learn web development
Frontend developer course
*
Getting started modules
*
Core modules
*
MDN Curriculum
*
Check out the video course from Scrimba, our partner
Learn HTML
*
Structuring content with HTML module
Learn CSS
*
CSS styling basics module
*
CSS layout module
Learn JavaScript
*
Dynamic scripting with JavaScript module
Tools
Discover our tools
*
Playground
*
HTTP Observatory
*
Border-image generator
*
Border-radius generator
*
Box-shadow generator
*
Color format converter
*
Color mixer
*
Shape generator
About
Get to know MDN better
*
About MDN
*
Advertise with us
*
Community
*
MDN on GitHub
Blog
Toggle sidebar
*
Web
*
JavaScript
*
Guide
Theme
*
OS default
*
Light
*
Dark
English (US)
Remember language
Learn more
*
Deutsch
*
English (US)
*
Español
*
Français
*
日本語
*
한국어
*
Português (do Brasil)
*
Русский
*
中文 (简体)
*
正體中文 (繁體)
JavaScript Guide
The JavaScript Guide shows you how to use JavaScript and gives an overview of the language. If you need exhaustive information about a language feature, have a look at the JavaScript reference .
This Guide is divided into the following chapters.
In this article
*
Introduction
*
Grammar and types
*
Control flow and error handling
*
Loops and iteration
*
Functions
*
Expressions and operators
*
Numbers and strings
*
Representing dates & times
*
Regular expressions
*
Indexed collections
*
Keyed collections
*
Working with objects
*
Using classes
*
Promises
*
Typed arrays
*
Iterators and generators
*
Resource management
*
Internationalization
*
JavaScript modules
*
Advanced topics
Introduction
Overview: Introduction
* About this guide
* About JavaScript
* JavaScript and Java
* ECMAScript
* Tools
* What's next
Grammar and types
Overview: Grammar and types
* Basic syntax & comments
* Declarations
* Variable scope
* Variable hoisting
* Data structures and types
* Literals
Control flow and error handling
Overview: Control flow and error handling
* if...else
* switch
* try / catch / throw
* Error objects
Loops and iteration
Overview: Loops and iteration
* for
* while
* do...while
* continue
* break
* for...in
* for...of
Functions
Overview: Functions
* Defining functions
* Calling functions
* Function scopes and closures
* Arguments & parameters
* Arrow functions
Expressions and operators
Overview: Expressions and operators
* Assignment & Comparisons
* Arithmetic operators
* Bitwise & logical operators
* Conditional (ternary) operator
Numbers and strings
Overview: Numbers and strings
* Numbers
* Number object
* Math object
* Strings
* String object
* Template literals
Representing dates & times
Overview: Representing dates & times
* Date object
Regular expressions
Overview: Regular expressions
* Creating a regular expression
* Writing a regular expression pattern
* Assertions
* Character classes
* Groups and backreferences
* Quantifiers
Indexed collections
Overview: Indexed collections
Keyed collections
Overview: Keyed collections
* Map
* WeakMap
* Set
* WeakSet
Working with objects
Overview: Working with objects
* Objects and properties
* Creating objects
* Defining methods
* Getter and setter
Using classes
Overview: Using classes
* Declaring a class
* Various class features
* Extends and inheritance
* Why classes?
Promises
Overview: Promises
* Guarantees
* Chaining
* Error handling
* Composition
* Timing
Typed arrays
Overview: Typed arrays
Iterators and generators
Overview: Iterators and generators
* Iterators
* Iterables
* Generators
Resource management
Overview: JavaScript resource management
* The using and await using declarations
* The DisposableStack and AsyncDisposableStack objects
* Error handling
Internationalization
Overview: Internationalization
* Date and time formatting
* Number formatting
* Collation
JavaScript modules
Overview: JavaScript modules
* Exporting
* Importing
* Default exports
* Renaming features
* Aggregating modules
* Dynamic module loading
Advanced topics
After you have learned all fundamental features of JavaScript, you can explore some more niche features, or dive deeper into the language's mechanisms and concepts.
* Language overview
* Data structures
* Enumerability and ownership of properties
* Inheritance and the prototype chain
* Equality comparisons and sameness
* Closures
* Meta programming
* Memory management
* Next
Help improve MDN
Yes
No
Learn how to contribute
This page was last modified on Nov 7, 2025 by MDN contributors .
View this page on GitHub • Report a problem with this content
Clear filter input
* JavaScript
* Tutorials and guides
* JavaScript Guide
* Introduction
* Grammar and types
* Control flow and error handling
* Loops and iteration
* Functions
* Expressions and operators
* Numbers and strings
* Representing dates & times
* Regular expressions
* Indexed collections
* Keyed collections
* Working with objects
* Using classes
* Using promises
* JavaScript typed arrays
* Iterators and generators
* Resource management
* Internationalization
* JavaScript modules
* Intermediate
* Language overview
* JavaScript data structures
* Equality comparisons and sameness
* Enumerability and ownership of properties
* Closures
* Advanced
* Inheritance and the prototype chain
* Meta programming
* Memory Management
* References
* Built-in objects
* AbstractModuleSource
* AggregateError
* Array
* ArrayBuffer
* AsyncDisposableStack
* AsyncFunction
* AsyncGenerator
* AsyncGeneratorFunction
* AsyncIterator
* Atomics
* BigInt
* BigInt64Array
* BigUint64Array
* Boolean
* DataView
* Date
* decodeURI()
* decodeURIComponent()
* DisposableStack
* encodeURI()
* encodeURIComponent()
* Error
* escape()
* eval()
* EvalError
* FinalizationRegistry
* Float16Array
* Float32Array
* Float64Array
* Function
* Generator
* GeneratorFunction
* globalThis
* Infinity
* Int8Array
* Int16Array
* Int32Array
* InternalError
* Intl
* isFinite()
* isNaN()
* Iterator
* JSON
* Map
* Math
* NaN
* Number
* Object
* parseFloat()
* parseInt()
* Promise
* Proxy
* RangeError
* ReferenceError
* Reflect
* RegExp
* Set
* SharedArrayBuffer
* String
* SuppressedError
* Symbol
* SyntaxError
* Temporal
* TypedArray
* TypeError
* Uint8Array
* Uint8ClampedArray
* Uint16Array
* Uint32Array
* undefined
* unescape()
* URIError
* WeakMap
* WeakRef
* WeakSet
* Expressions & operators
* Addition (+)
* Addition assignment (+=)
* Assignment (=)
* async function expression
* async function* expression
* await
* Bitwise AND (&)
* Bitwise AND assignment (&=)
* Bitwise NOT (~)
* Bitwise OR (|)
* Bitwise OR assignment (|=)
* Bitwise XOR (^)
* Bitwise XOR assignment (^=)
* class expression
* Comma operator (,)
* Conditional (ternary) operator
* Decrement (--)
* delete
* Destructuring
* Division (/)
* Division assignment (/=)
* Equality (==)
* Exponentiation (**)
* Exponentiation assignment (**=)
* function expression
* function* expression
* Greater than (>)
* Greater than or equal (>=)
* Grouping operator ( )
* import.meta
* import.meta.resolve()
* import()
* import.source()
* in
* Increment (++)
* Inequality (!=)
* instanceof
* Left shift (<<)
* Left shift assignment (<<=)
* Less than (<)
* Less than or equal (<=)
* Logical AND (&&)
* Logical AND assignment (&&=)
* Logical NOT (!)
* Logical OR (||)
* Logical OR assignment (||=)
* Multiplication (*)
* Multiplication assignment (*=)
* new
* new.target
* null
* Nullish coalescing assignment (??=)
* Nullish coalescing operator (??)
* Object initializer
* Operator precedence
* Optional chaining (?.)
* Property accessors
* Remainder (%)
* Remainder assignment (%=)
* Right shift (>>)
* Right shift assignment (>>=)
* Spread syntax (...)
* Strict equality (===)
* Strict inequality (!==)
* Subtraction (-)
* Subtraction assignment (-=)
* super
* this
* typeof
* Unary negation (-)
* Unary plus (+)
* Unsigned right shift (>>>)
* Unsigned right shift assignment (>>>=)
* void operator
* yield
* yield*
* Statements & declarations
* async function
* async function*
* await using
* Block statement
* break
* class
* const
* continue
* debugger
* do...while
* Empty statement
* export
* Expression statement
* for
* for await...of
* for...in
* for...of
* function
* function*
* if...else
* import
* Import attributes
* import source
* Labeled statement
* let
* return
* switch
* throw
* try...catch
* using
* var
* while
* with
* Functions
* Arrow function expressions
* Default parameters
* get
* Method definitions
* Rest parameters
* set
* The arguments object
* [Symbol.iterator]()
* callee
* length
* Classes
* constructor
* extends
* Private elements
* Public class fields
* static
* Static initialization blocks
* Regular expressions
* Backreference: \1, \2
* Buffer boundary assertion: \A, \z, \Z
* Capturing group: (...)
* Character class escape: \d, \D, \w, \W, \s, \S
* Character class: [...], [^...]
* Character escape: \n, \u{...}
* Disjunction: |
* Input boundary assertion: ^, $
* Literal character: a, b
* Lookahead assertion: (?=...), (?!...)
* Lookbehind assertion: (?<=...), (?<!...)
* Modifier: (?ims-ims:...)
* Named backreference: \k<name>
* Named capturing group: (?<name>...)
* Non-capturing group: (?:...)
* Quantifier: *, +, ?, {n}, {n,}, {n,m}
* Unicode character class escape: \p{...}, \P{...}
* Wildcard: .
* Word boundary assertion: \b, \B
* Errors
* AggregateError: No Promise in Promise.any was resolved
* Error: Permission denied to access property "x"
* InternalError: too much recursion
* RangeError: argument is not a valid code point
* RangeError: BigInt division by zero
* RangeError: BigInt negative exponent
* RangeError: form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD'
* RangeError: invalid array length
* RangeError: invalid date
* RangeError: precision is out of range
* RangeError: radix must be an integer
* RangeError: repeat count must be less than infinity
* RangeError: repeat count must be non-negative
* RangeError: x can't be converted to BigInt because it isn't an integer
* ReferenceError: "x" is not defined
* ReferenceError: assignment to undeclared variable "x"
* ReferenceError: can't access lexical declaration 'X' before initialization
* ReferenceError: must call super constructor before using 'this' in derived class constructor
* ReferenceError: super() called twice in derived class constructor
* SyntaxError: 'arguments'/'eval' can't be defined or assigned to in strict mode code
* SyntaxError: "0"-prefixed octal literals are deprecated
* SyntaxError: "use strict" not allowed in function with non-simple parameters
* SyntaxError: "x" is a reserved identifier
* SyntaxError: \ at end of pattern
* SyntaxError: a declaration in the head of a for-of loop can't have an initializer
* SyntaxError: applying the 'delete' operator to an unqualified name is deprecated
* SyntaxError: arguments is not valid in fields
* SyntaxError: await is only valid in async functions, async generators and modules
* SyntaxError: await/yield expression can't be used in parameter
* SyntaxError: cannot use ?? unparenthesized within || and && expressions
* SyntaxError: character class escape cannot be used in class range in regular expression
* SyntaxError: continue must be inside loop
* SyntaxError: duplicate capture group name in regular expression
* SyntaxError: duplicate formal argument x
* SyntaxError: for-in loop head declarations may not have initializers
* SyntaxError: function statement requires a name
* SyntaxError: functions cannot be labelled
* SyntaxError: getter and setter for private name #x should either be both static or non-static
* SyntaxError: getter functions must have no arguments
* SyntaxError: identifier starts immediately after numeric literal
* SyntaxError: illegal character
* SyntaxError: import declarations may only appear at top level of a module
* SyntaxError: incomplete quantifier in regular expression
* SyntaxError: invalid assignment left-hand side
* SyntaxError: invalid BigInt syntax
* SyntaxError: invalid capture group name in regular expression
* SyntaxError: invalid character in class in regular expression
* SyntaxError: invalid class set operation in regular expression
* SyntaxError: invalid decimal escape in regular expression
* SyntaxError: invalid identity escape in regular expression
* SyntaxError: invalid named capture reference in regular expression
* SyntaxError: invalid property name in regular expression
* SyntaxError: invalid range in character class
* SyntaxError: invalid regexp group
* SyntaxError: invalid regular expression flag "x"
* SyntaxError: invalid unicode escape in regular expression
* SyntaxError: JSON.parse: bad parsing
* SyntaxError: label not found
* SyntaxError: missing : after property id
* SyntaxError: missing ) after argument list
* SyntaxError: missing ) after condition
* SyntaxError: missing ] after element list
* SyntaxError: missing } after function body
* SyntaxError: missing } after property list
* SyntaxError: missing = in const declaration
* SyntaxError: missing formal parameter
* SyntaxError: missing name after . operator
* SyntaxError: missing variable name
* SyntaxError: negated character class with strings in regular expression
* SyntaxError: new keyword cannot be used with an optional chain
* SyntaxError: nothing to repeat
* SyntaxError: numbers out of order in {} quantifier.
* SyntaxError: octal escape sequences can't be used in untagged template literals or in strict mode code
* SyntaxError: parameter after rest parameter
* SyntaxError: private fields can't be deleted
* SyntaxError: property name __proto__ appears more than once in object literal
* SyntaxError: raw bracket is not allowed in regular expression with unicode flag
* SyntaxError: redeclaration of formal parameter "x"
* SyntaxError: reference to undeclared private field or method #x
* SyntaxError: rest parameter may not have a default
* SyntaxError: return not in function
* SyntaxError: setter functions must have one argument
* SyntaxError: string literal contains an unescaped line break
* SyntaxError: super() is only valid in derived class constructors
* SyntaxError: tagged template cannot be used with optional chain
* SyntaxError: Unexpected '#' used outside of class body
* SyntaxError: Unexpected token
* SyntaxError: unlabeled break must be inside loop or switch
* SyntaxError: unparenthesized unary expression can't appear on the left-hand side of '**'
* SyntaxError: use of super property/member accesses only valid within methods or eval code within methods
* SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead
* TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed
* TypeError: 'x' is not iterable
* TypeError: "x" is (not) "y"
* TypeError: "x" is not a constructor
* TypeError: "x" is not a function
* TypeError: "x" is not a non-null object
* TypeError: "x" is read-only
* TypeError: already executing generator
* TypeError: BigInt value can't be serialized in JSON
* TypeError: calling a builtin X constructor without new is forbidden
* TypeError: can't access/set private field or method: object is not the right class
* TypeError: can't assign to property "x" on "y": not an object
* TypeError: can't convert BigInt to number
* TypeError: can't convert x to BigInt
* TypeError: can't define property "x": "obj" is not extensible
* TypeError: can't delete non-configurable array element
* TypeError: can't redefine non-configurable property "x"
* TypeError: can't set prototype of this object
* TypeError: can't set prototype: it would cause a prototype chain cycle
* TypeError: cannot use 'in' operator to search for 'x' in 'y'
* TypeError: class constructors must be invoked with 'new'
* TypeError: cyclic object value
* TypeError: derived class constructor returned invalid value x
* TypeError: getting private setter-only property
* TypeError: Initializing an object twice is an error with private fields/methods
* TypeError: invalid 'instanceof' operand 'x'
* TypeError: invalid Array.prototype.sort argument
* TypeError: invalid assignment to const "x"
* TypeError: Iterator/AsyncIterator constructor can't be used directly
* TypeError: matchAll/replaceAll must be called with a global RegExp
* Typ
Links found on this page
- Skip to main content [direct]
- HTML: Markup language [direct]
- Elements [direct]
- Global attributes [direct]
- Attributes [direct]
- See all… [direct]
- Responsive images [direct]
- HTML cheatsheet [direct]
- Date & time formats [direct]
- See all… [direct]
- SVG [direct]
- MathML [direct]
- XML [direct]
- CSS: Styling language [direct]
- Properties [direct]
- Selectors [direct]
- At-rules [direct]
- Values [direct]
- See all… [direct]
- Box model [direct]
- Animations [direct]
- Flexbox [direct]
- Colors [direct]
- See all… [direct]
- Column layouts [direct]
- Centering an element [direct]
- Card component [direct]
- See all… [direct]
- JavaScript: Scripting language [direct]
- Standard built-in objects [direct]
- Expressions & operators [direct]
- Statements & declarations [direct]
- Functions [direct]
- See all… [direct]
- Control flow & error handing [direct]
- Loops and iteration [direct]
- Working with objects [direct]
- Using classes [direct]
- Web APIs: Programming interfaces [direct]
- File system API [direct]
- Fetch API [direct]
- Geolocation API [direct]
- HTML DOM API [direct]
- Push API [direct]
- Service worker API [direct]
- Using the Web animation API [direct]
- Using the Fetch API [direct]
- Working with the History API [direct]
- Using the Web speech API [direct]
- Using web workers [direct]
- All web technology [direct]
- Accessibility [direct]
- HTTP [direct]
- URI [direct]
- Web extensions [direct]
- WebAssembly [direct]
- WebDriver [direct]
- Media [direct]
- Performance [direct]
- Privacy [direct]
- Security [direct]
- Progressive web apps [direct]
- Learn web development [direct]
- Getting started modules [direct]
- Core modules [direct]
- MDN Curriculum [direct]
- Check out the video course from Scrimba, our partner [direct]
- Structuring content with HTML module [direct]
- CSS styling basics module [direct]
- CSS layout module [direct]
- Dynamic scripting with JavaScript module [direct]
- Playground [direct]
- HTTP Observatory [direct]
- Border-image generator [direct]
- Border-radius generator [direct]
- Box-shadow generator [direct]
- Color format converter [direct]
- Color mixer [direct]
- Shape generator [direct]
- About MDN [direct]
|
|