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

bookConstant 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
Tarefa

Swipe to start coding

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

Solução

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.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 11
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain why the code sample results in an error?

What is the difference between `let`, `const`, and `var` regarding hoisting?

Can you give more examples of using `const` correctly?

close

bookConstant 3/3

Deslize para mostrar o menu

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
Tarefa

Swipe to start coding

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

Solução

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 11
single

single

some-alt