From 375e702b5777b721451663f0aef4696ba3900a10 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 19 Dec 2018 07:20:01 +0000 Subject: [PATCH] Update let (#24190) * Update index.md * Formatting changes --- guide/english/javascript/es6/let-and-const/index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guide/english/javascript/es6/let-and-const/index.md b/guide/english/javascript/es6/let-and-const/index.md index b454aef02b..6bfa3f940b 100644 --- a/guide/english/javascript/es6/let-and-const/index.md +++ b/guide/english/javascript/es6/let-and-const/index.md @@ -29,6 +29,19 @@ console.log(c); // 10 console.log(a); // 50 ``` +### Differences with `var` + +Hoisting - `let` variables are not initialized until their definition is evaluated: + +```js +function action() { + console.log(a); // undefined + console.log(b); // ReferenceError + var a = 1; + let b = 2; +} +``` + ## Const Const is used to assign a constant value to the variable, and the value cannot be changed. It is fixed.