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

Sveip for å vise menyen

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.

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

Swipe to start coding

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

Løsning

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.

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 11
Vi beklager at noe gikk galt. Hva skjedde?

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

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.

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

Swipe to start coding

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

Løsning

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.

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 11
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt