codegurukool.com · Free coding tutorials & online compiler

Home › JavaScript Tutorial › JS versions

JS versions

ECMAScript editions.

ES5 (2009) added strict mode. ES6 (2015) brought let, const, arrows, classes, promises and modules. Since then one update arrives each year, such as ?. and ??, at() and Object.groupBy.

Commands in this lesson

let

Definition: Declares a variable that can change. It lives inside its block.

Syntax:

let name = value;

Example:

let n = 1;
n = n + 1;
console.log(n);

const

Definition: Declares a variable that cannot be reassigned.

Syntax:

const name = value;

Example:

const pi = 3.14;
console.log(pi);

Example code

<pre id='o'></pre>
<script>
const u={a:{b:1}};
o.textContent=[u?.a?.b,u?.x?.y,[1,2,3].at(-1),typeof structuredClone].join('\n');
</script>

Run this code in the online editor

← JS style guideJS DOM navigation →