Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Constants | Manipulating Data
Introduction to JavaScript
course content

Kursinnhold

Introduction to JavaScript

Introduction to JavaScript

1. Getting Started
3. Conditional Statements
4. Mastering Functions
5. Exploring Arrays
6. Discovering Loops

book
Constants

Note
Definition

Constants are similar to variables however their value, as expressed by the name, is always constant or unchanged.

We can declare a constant using the const keyword, and it's important to initialize it at the same point as well. Following is the syntax for constant declaration & initialization:

js

For example:

js

Changing the value of a constant results in an error:

js

The names of the constants follow the same naming rules as the variables.

1. What is a constant in JavaScript?

2. Which keyword is used to declare a constant in JavaScript?

3. What happens if you try to reassign a value to a constant?

4. Which of the following correctly declares and initializes a constant in a single statement?

question mark

What is a constant in JavaScript?

Select the correct answer

question mark

Which keyword is used to declare a constant in JavaScript?

Select the correct answer

question mark

What happens if you try to reassign a value to a constant?

Select the correct answer

question mark

Which of the following correctly declares and initializes a constant in a single statement?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 6

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

course content

Kursinnhold

Introduction to JavaScript

Introduction to JavaScript

1. Getting Started
3. Conditional Statements
4. Mastering Functions
5. Exploring Arrays
6. Discovering Loops

book
Constants

Note
Definition

Constants are similar to variables however their value, as expressed by the name, is always constant or unchanged.

We can declare a constant using the const keyword, and it's important to initialize it at the same point as well. Following is the syntax for constant declaration & initialization:

js

For example:

js

Changing the value of a constant results in an error:

js

The names of the constants follow the same naming rules as the variables.

1. What is a constant in JavaScript?

2. Which keyword is used to declare a constant in JavaScript?

3. What happens if you try to reassign a value to a constant?

4. Which of the following correctly declares and initializes a constant in a single statement?

question mark

What is a constant in JavaScript?

Select the correct answer

question mark

Which keyword is used to declare a constant in JavaScript?

Select the correct answer

question mark

What happens if you try to reassign a value to a constant?

Select the correct answer

question mark

Which of the following correctly declares and initializes a constant in a single statement?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 6
Vi beklager at noe gikk galt. Hva skjedde?
some-alt