2

I'm new to nodejs. I've been watching tutorials on Youtube and some use 'const' as opposed to 'var' which I'm familiar with in Javascript. I figured 'const' should mean constant and 'var'-variable. But I still don't get it. Why would you need to use 'const' instead of 'var'?

Red Bottle
  • 2,839
  • 4
  • 22
  • 59

1 Answers1

4

A similar question here:

Const in javascript? When to use it and is it necessary

If you are using ES6, you may want to look into using "let" vs "var". "let" is a safer choice as it is scoped and var is not. You can read more about that here:

https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75#.xhhshyeaa

Community
  • 1
  • 1
John Lee
  • 1,357
  • 1
  • 13
  • 26