let, cont, Var Flashcards

1
Q

What are the three ways of declaring variables in JavaScript?

A

let, const, Var

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain let

A

let is used to declare variables that can change during the execution of a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain const

A

const is used to create immutable variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain Var

A

var is the old way of declaring variables prior to ES6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can empty const variables be declared.

A

No, empty const variables can not be declared. This is because const variables are immutable and their values cannot be reassigned.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is it good practice to have as little variable mutations as possible?

A

This is because changing variables introduces a potential to create bugs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly