Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (55.6k points)

Can anyone explain the const in Node Js?

1 Answer

0 votes
by (119k points)
edited by

Const is the variables declared with the keyword const that stores constant values. const declarations are block-scoped i.e. we can access const only within the block where it was declared.

const cannot be updated or re-declared i.e. const will be the same within its block and cannot be re-declare or update.

So, after declaring a variable with const, we cannot do the following:

const greeting = "say Hi";

greeting = "say Hello instead";

 Output

 error: Assignment to constant variable

const greeting = "say Hi";

const greeting = "say Hello instead";

Output:

error: Identifier 'greeting' has already been declared

If you want to learn Node Js from an online course, you can enroll in this Node Js Course by Intellipaat

Also, watch this video on Node Js:

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 9, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Sep 9, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Sep 9, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Sep 9, 2020 in Web Technology by Sudhir_1997 (55.6k points)

Browse Categories

...