Mark As Completed Discussion

Reassigning variables

Values can be reassigned to variables in JavaScript (except const variables, which we will discuss later). When variables are reassigned, their value changes to that of the newer value specified, and the previous value is lost.

Reassignment of Variables

Let's look at an example.

Variables can be reassigned in JavaScript by assigning a new value to the variable without using the var keyword.

JAVASCRIPT
1var a = 10;
2a = 34;

Initially, when creating the variable we used the var keyword, but when reassigning there is no need to use the keyword again. We only provide a different value than what was stored before. The value of a is reassigned from 10 to 34.