Javascript keyword

Hi guys.
I seem to have a problem knowing when to use let or const keywords from var keywords and how it can be applied to real-world problem.

My advice, never use var unless you have a very unique situation in which it would be advantageous, which is almost never, so just don’t use it.

Most developers will tell you to always use const and then only use let when you know the value it is pointing to will need to change.

In summary:

  1. Always use const, but…
  2. Use let when the value needs to change
  3. Never use var

Remember, you can use const for objects and arrays and still change the values inside of the object/array.

Thank you very much.This is very helpful.Will work towards that!Perhaps one should assume that there was never a keyword ‘var’.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.