Javascript ES6 Declarations Guide.
Understanding 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
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.