Javascript ES6 Declarations Guide.

Understanding var, let and const in JavaScript ES6 Variables.

Anwar Gul
The Startup

--

var, let and const in JavaScript ES6 Variables

In this article, we will be discussing the very fundamental and the basic building block in your javascript programming journey i.e Variables.

In JavaScript, there are three keywords used to declare a variable var, let, and const and each one affects how the code will interpret the variable differently.

NOTE: JavaScript only hoist declarations, not initializations. So all declarations are hoisted.

1- VAR

Declaration Syntax with Var Keyword

This statement consists of a few parts:

  • The declaration of a variable using the var keyword
  • The variable name (or identifier), author
  • The assignment operation, represented by the = syntax
  • The value being assigned, "Anwar"

Declarations with var keyword can either be of global scope or function scope depending on the current execution context.

--

--

Anwar Gul
The Startup

👨‍💻 Web Developer | 📱Mobile App Developer | Software Engineer by Profession. JS enthusiast by Passion❤️ . Follow me on Twitter https://twitter.com/anwargul0x