Skip to content

Commit 4bb034f

Browse files
committed
Adding slides
1 parent df9ade2 commit 4bb034f

1 file changed

Lines changed: 65 additions & 81 deletions

File tree

‎Topics/07. ES6-Features/README.md‎

Lines changed: 65 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<!-- section start -->
2-
3-
4-
2+
<!-- attr: { id:'', class:'slide-title', showInPresentation:true, hasScriptWrapper:true } -->
3+
# ES 2015 Features
4+
## The new cool stuff in JS
5+
<article class="signature">
6+
<p class="signature-course">JavaScript OOP</p>
7+
<p class="signature-initiative">Telerik Software Academy</p>
8+
<a href="http://academy.telerik.com " class="signature-link">http://academy.telerik.com </a>
9+
</div>
510

611
<!-- section start -->
12+
713
<!-- attr: { id:'', showInPresentation:true, hasScriptWrapper:true } -->
814
# Table of Contents
915
- JavaScript History
@@ -25,7 +31,7 @@
2531
- Binary, Octal and hexadecimal literals
2632
- Math methods
2733
- Functions
28-
- Arraw functions
34+
- Arrоw functions
2935
- Preserving `this`
3036
- Generators
3137
- Arrays
@@ -46,47 +52,41 @@
4652
- Default
4753
- rest operator
4854

49-
50-
51-
5255
<!-- section start -->
5356

54-
5557
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
5658
# JavaScript History
5759
- **JavaScript** is a front-end scripting language developed by Netscape for dynamic content
5860
- Lightweight, but with limited capabilities
5961
- Can be used as object-oriented language
6062
- Embedded in your HTML page
6163
- Interpreted by the Web browser
62-
- **Client-side**, **mobile**and**desktop** technology
64+
- **Client-side**, **mobile** and **desktop** technology
6365
- Simple and flexible
6466
- Powerful to manipulate the DOM
6567

66-
67-
68-
6968
<!-- section start -->
7069

7170

72-
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
73-
# Using JavaScript.next
74-
- There are a few ways to use JavaScript.next today
75-
- Enable tags in Chrome and Firefox
76-
- Compile to JavaScript 5 using Traceur or Babel
77-
- A compatibility table for ES6 support can be found at https://kangax.github.io/compat-table/es6/
7871

72+
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
73+
# Using ES 2015
74+
- There are a few ways to use ES 2015 today:
75+
- Most browsers already support it
76+
- Node.js 6.X supports it
77+
- For support for older browsers (IE 8, 9):
78+
- Transpilers: **Babel**, **Traceur**
79+
- A compatibility table for ES6 support can be found at https://kangax.github.io/compat-table/es6/
7980

8081

8182

8283
<!-- section start -->
8384

84-
8585
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
8686
# ES6 Variables
8787
- ES6 introduces new ways to declare variables:
88-
- let – creates a scope variable
89-
- Accessible only in its scope
88+
- `let` – creates a scoped variable
89+
- Accessible only in its own scope
9090

9191
```javascript
9292
for(let number of [1, 2, 3, 4]){
@@ -95,7 +95,7 @@ for(let number of [1, 2, 3, 4]){
9595
//accessing number here throws exception
9696
```
9797

98-
- const – creates a constant variable
98+
- `const` – creates a constant variable
9999
- Its value is read-only and cannot be changed
100100

101101
```javascript
@@ -105,51 +105,61 @@ MAX_VALUE = 15; // throws exception
105105

106106

107107

108-
109-
110-
111-
112108
<!-- section start -->
113109

114-
115110
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
116-
# For-of loop
111+
# Loops
117112

118-
```javascript
119-
The for-of loop iterates over the values
120-
Of an array
121-
```
113+
- ES 2015 has a new kind of `for` loop
114+
- `for-of` iterates though the members of an array:
122115

123-
- function* generator(maxValue){
124-
- for(let i = 0; i < maxValue; i+=1) {
125-
- yield i;
126-
- }
127-
- }
128-
- let iter = generator(10);
129-
- for(let val of iter()){
130-
- console.log(val);
131-
- }
116+
```javascript
117+
let numbers = [1, 2, 3, 5];
118+
for(let number of numbers) {
119+
console.log(`The number is ${number}`);
120+
}
121+
```
132122

133-
```javascript
134-
let sum = 0;
135-
for(let number of [1, 2, 3]) {
136-
sum += number; }
137-
```
123+
- Or iteratable objects (objects that have `Symbol.iterator`):
124+
- Discussed in detail later
138125

126+
```javascript
127+
let fib = {
128+
[Symbol.iterator]() {
129+
//magic code to return next Fibonacci number
130+
}
131+
};
139132
140-
```javascript
141-
Of An iteratable object
142-
```
133+
let i = 0;
134+
for (let number of obj) {
135+
if (i > 10) {
136+
break;
137+
}
138+
i += 1;
139+
console.log(number);
140+
}
141+
```
143142

144143

145144

145+
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
146+
# Data Structures
147+
- ES6 supports maps and sets natively
148+
- They do pretty much the same as associative arrays, but in cleaner way:
146149

150+
```javascript
151+
let names = new Set();
152+
names.add('Doncho');
153+
names.add('Nikolay');
154+
names.add('Ivaylo');
155+
names.add('Evlogi');
156+
names.add('Doncho'); // won't be added
157+
```
147158

148159

149160

150161
<!-- section start -->
151162

152-
153163
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
154164
# Templated Strings in ES6
155165
- ES6 supports templated strings
@@ -306,7 +316,7 @@ numbers.sort((a, b) => b – a);
306316

307317

308318
```javascript
309-
var fullnames =
319+
var fullnames =
310320
people.filter(function (person) {
311321
return person.age >= 18;
312322
}).map(function (person) {
@@ -338,7 +348,7 @@ numbers.sort((a, b) => b – a);
338348

339349

340350
```javascript
341-
var fullnames =
351+
var fullnames =
342352
people.filter(function (person) {
343353
return person.age >= 18;
344354
}).map(function (person) {
@@ -348,7 +358,7 @@ var fullnames =
348358

349359

350360
```javascript
351-
var fullnames2 =
361+
var fullnames2 =
352362
people.filter(p => p.age >= 18)
353363
.map(p => p.fullname);
354364
```
@@ -375,7 +385,7 @@ Becomes
375385
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
376386
# Object Literals
377387
- ES6 adds a new feature (rule) to the way of defining properties:
378-
- Instead of
388+
- Instead of
379389

380390
```javascript
381391
let name = 'Doncho Minkov',
@@ -454,28 +464,6 @@ var {name, address: {city}} = person;
454464

455465

456466

457-
<!-- section start -->
458-
459-
460-
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
461-
# Maps and Sets
462-
- ES6 supports maps and sets natively
463-
- They do pretty much the same as associative arrays, but in cleaner way:
464-
465-
```javascript
466-
let names = new Set();
467-
names.add('Doncho');
468-
names.add('Nikolay');
469-
names.add('Ivaylo');
470-
names.add('Evlogi');
471-
names.add('Doncho'); // won't be added
472-
```
473-
474-
475-
476-
477-
478-
479467

480468
<!-- section start -->
481469

@@ -540,8 +528,4 @@ f(1, 2, ...params) // 9
540528

541529
<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
542530
# JavaScript.next
543-
- http://academy.telerik.com
544-
545-
546-
547-
531+
- http://academy.telerik.com

0 commit comments

Comments
 (0)