You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-2Lines changed: 58 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,12 +103,43 @@ Each proposal for an ECMAScript feature goes through the following maturity stag
103
103
104
104
1.### Variable Scoping
105
105
106
-
The variable scoping determines the visibility or accessibility of a variable within the certain part of the program or region. In ES6, both `const` and `let` keywords allow developers to declare variables in the block scope.
107
-
The `let` statement declares a block-scoped local variable
106
+
The variable scoping determines the visibility or accessibility of a variable within the certain part of the program or region.
107
+
108
+
In ES6, both `const` and `let` keywords allow developers to declare variables in the block scope.
109
+
110
+
The `let` statement declares a block-scoped local variable which can be reassigned. i.e, `let` declaration creates a mutable variable.
111
+
112
+
```js
113
+
let a =1;
114
+
115
+
if (a ===1) {
116
+
let a =2;
117
+
118
+
console.log(a); //2
119
+
}
120
+
121
+
console.log(a); //1
122
+
```
123
+
124
+
**const** variables are similar to **let** variables but they can't be changed through reassignment. i.e, The const declaration creates a read-only reference to a value.
125
+
126
+
```js
127
+
consta=1;
128
+
129
+
if (a ===1) {
130
+
constb=2; // You cannot re-assign the value similar to let variable
131
+
132
+
console.log(b); //2
133
+
}
134
+
135
+
console.log(a); //1
136
+
```
137
+
108
138
109
139
2.### Arrow functions
110
140
111
141
The arrow functions provides a more concise syntax for writing function expressions by opting out the function and return keywords using fat arrow(=>) notation. Let's see how this arrow function looks like,
142
+
112
143
```js
113
144
// Function Expression
114
145
varmultiplyFunc=function(a, b) {
@@ -195,6 +226,31 @@ const square = class Square {
195
226
}
196
227
```
197
228
229
+
You can use **extend** keyword to use inheritance. This enables the subclass to get all features of a parent class.
230
+
231
+
```js
232
+
classVehicle {
233
+
constructor(name) {
234
+
this.name= name;
235
+
}
236
+
237
+
start() {
238
+
console.log(`${this.name} vehicle started`);
239
+
}
240
+
}
241
+
242
+
classCarextendsVehicle {
243
+
start() {
244
+
console.log(`${this.name} car started`);
245
+
}
246
+
}
247
+
248
+
constcar=newCar('BMW');
249
+
console.log(car.start()); // BMW car started
250
+
```
251
+
252
+
**Note:** Even though ES6 classes looks similar to classes in other object oriented languages, such as Java, PHP, etc but they do not work exactly the same way.
253
+
198
254
### Enhanced object literals
199
255
Object literals are extended to support setting the prototype at construction, shorthand for foo: foo assignments, defining methods, making super calls, and computing property names with expressions.
0 commit comments