0

When and where should I use var, let, and const in JavaScript? I am aware that let variables can be reassigned to a new value but const variables cannot be reassigned to a new value. When I write JS code, I find myself using let almost all the time just because it allows reassignments. Is there any case where using const would be preferable? Also, is there any scenario where I should still be using var?

  • Does this answer of your question? https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/ – Tariq Ahmed Dec 04 '21 at 06:16
  • Welcome to Stack Overflow! Please visit [help], take [tour] to see what and [ask]. [Do some research](https://www.google.com/search?q=var+let+const+site%3Astackoverflow.com), search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output, preferably in a [Stacksnippet](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) – mplungjan Dec 04 '21 at 06:17

0 Answers0