Variables in Javascript which can take variable values during program execution. But if you want to work with constants like PI, you can make use of *const*.

The syntax is

const name [= value];

The best example for a const is PI (used in various mathematical formulas)

const pi = 3.14;

There are some more things that one can understand from the above syntax. The following line is completely fine

const interest;

If you have followed the post on assignment of variables, you will know that *interest* has the value **undefined**.

Now let’s try to declare interest again

const interest;
const interest = 3.0;

You will get the following error

TypeError: redeclaration of const interest

But the following statements are totally fine

var interest;
var interest = 3.0;

This is because constants once declared remains same throughout the program and cannot be declared once again

### Like this:

Like Loading...

*Related*