Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Constant 3/3 | Data Types and Variables
Introduction to JavaScript

book
Constant 3/3

const Does Not Allow Hoisting

As discussed in the previous chapter, let does not allow hoisting i.e. we cannot use a variable before the declaration. Just like let we can not use hoisting with the const.it is only supported with var.

MYPLANET = 'earth';
console.log(MYPLANET);
const MYPLANET;
123
MYPLANET = 'earth'; console.log(MYPLANET); const MYPLANET;
copy
Taak

Swipe to start coding

Rearrange the following code to display the value of SALARY on the console.

Oplossing

const SALARY = 12000;
console.log(SALARY);

Summary:

  • We can neither change the values of the const variables through reassignment nor we can redeclare them.

  • Value should be assigned to const variables at the time of declaration.

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 11
single

single

SALARY=12000;
console.log(SALARY);
const SALARY;

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt