Back

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

Can anyone tell me the difference between var and const in Node Js?

1 Answer

0 votes
by (119k points)
edited by

Var declarations can be either globally scoped or function scoped. It is globally scoped if the var variable is declared outside a function can be used anywhere in the whole window. The var is function scoped when it is declared within a function and be used only inside the function.

#Declaring variable var

var greeter = ‘hi’

const are the variables declared with the const and can maintain only constant values. Const declarations can only be accessed inside the block only where it was declared.

#Declaring const

const greeting = ‘hi’

The main difference between var and const is var can be re-declared and updated and const cannot be re-declared or updated.

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

Also, watch this video on Node Js:

Related questions

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

Browse Categories

...