Var, let, and const, what's the difference | freeCodeCamp

var is globally scoped and hoisted, which can lead to unintended side effects. let is block-scoped and can never be redeclared within that scope – much harder to break, but need to be careful about passing it to where it's needed and aware that it is still hoisted, albeit with no value (not even null). const works similarly to let, but you cannot update the value (though you can update internal values).

Explore Other Notes

Newer

The React cheatsheet for 2020

A very hand overview of the core concepts in React, from JSX to fragments to hooks. Includes quick reference to the core hooks and how/when to use them e.g. useState, useContext, useMemo […]
  • var is globally scoped and hoisted, which can lead to unintended side effects. let is block-scoped and can never be redeclared within that scope – much harder to break, but need to be careful about […]
  • Murray Adcock.
Journal permalink

Made By Me, But Made Possible By:

CMS:

Build: Gatsby

Deployment: GitHub

Hosting: Netlify

Connect With Me:

Twitter Twitter

Instagram Instragram

500px 500px

GitHub GitHub

Keep Up To Date:

All Posts RSS feed.

Articles RSS feed.

Journal RSS feed.

Notes RSS feed.