Skip to content

Commit 635c8c1

Browse files
Typo
1 parent 371a4aa commit 635c8c1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ebook/01_var_let_const.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ constant = " I can't be reassigned";
7777
// Uncaught TypeError: Assignment to constant variable
7878
```
7979

80-
>**Important**:
81-
This **does not** mean that variables declared with `const` are immutable.
80+
> **Important**:
81+
> This **does not** mean that variables declared with `const` are immutable.
8282
8383
 
8484

@@ -95,11 +95,11 @@ console.log(person.age);
9595
// 26
9696
```
9797

98-
In this case we are not reassigning the whole variable but just one of its properties, which works fine fine.
98+
In this case we are not reassigning the whole variable but just one of its properties, which works fine.
9999

100100
---
101101

102-
>Note: We can still freeze the `const` object, which will not change the contents of the object (but trying to change the values of object `JavaScript` will not throw any error).
102+
> Note: We can still freeze the `const` object, which will not change the contents of the object (but trying to change the values of object `JavaScript` will not throw any error).
103103
104104
```JavaScript
105105
const person = {
@@ -129,12 +129,12 @@ First let's have a look at a simple example:
129129

130130
```javascript
131131
console.log(i);
132-
var i = "I am a variable";
132+
var i = 'I am a variable';
133133

134134
// expected output: undefined
135135

136136
console.log(j);
137-
let j = "I am a let";
137+
let j = 'I am a let';
138138

139139
// expected output: ReferenceError: can't access lexical declaration `j' before initialization
140140
```
@@ -147,19 +147,20 @@ Despite what you may read on other sources, both `var` and `let`(and `const`) ar
147147
The main differences lie in the fact that `var` can still be accessed before they are defined. This causes the value to be `undefined`. While on the other hand, `let` lets the variables sit in a **temporal dead zone** until they are declared. And this causes an error when accessed before initialization, which makes it easier to debug code rather than having an `undefined` as the result.
148148

149149
---
150+
150151
 
151152

152153
## When to use `Var`, `Let` and `Const`
153154

154155
There is no rule stating where to use each of them, and people have different opinions. Here I am going to present to you two opinions from popular developers in the `JavaScript` community.
155156

156-
The first opinion comes from [Mathias Bynes:](https://mathiasbynens.be/notes/es6-const)
157+
The first opinion comes from [Mathias Bynes](https://mathiasbynens.be/notes/es6-const):
157158

158159
- Use `const` by default
159160
- Use `let` only if rebinding is needed.
160161
- `var` should never be used in ES6.
161162

162-
The second opinion comes from [Kyle Simpson:](https://me.getify.com/)
163+
The second opinion comes from [Kyle Simpson](https://me.getify.com/):
163164

164165
- Use `var` for top-level variables that are shared across many (especially larger) scopes.
165166
- Use `let` for localized variables in smaller scopes.

0 commit comments

Comments
 (0)