Favorites

JavaScript const Declaration

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
const
JavaScript DeclarationsThis declaration is supported by all modern browsers.
Updated 28th November 2026

The const declaration creates a block-scoped variable that must be given a value and can't be reassigned. Objects it holds can still be changed.

Description

The const declaration creates a block-scoped variable that can't be reassigned. It must be initialized in the declaration, and like let it can't be used before that line (the temporal dead zone).

const makes the binding constant, not the value. An object or array stored in a const can still have its contents changed; use Object.freeze() to prevent that. Many style guides use const by default and let only for variables that will be reassigned, which makes code easier to follow.

Declaring something with const tells anyone reading the code that the name will always refer to the same value, which makes code easier to reason about. It works with destructuring, const { name, age } = user, and in for...of and for...in loops, where each iteration gets a fresh binding. It can't be used for the counter in a classic for loop, because the counter is reassigned on every pass.

Syntax

const name = value;
const name1 = value1, name2 = value2;

Example

const PI = 3.14159;
try { PI = 3; } catch (e) { console.log(e.name); }

const list = ['a'];
list.push('b');
console.log(list);

for (const item of list) console.log(item);

Browser Support

The following information will show you the current browser support for the const declaration. Hover over a browser icon to see the version that first introduced support for this declaration.

This declaration is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee