+ All Categories
Home > Technology > What is new on ES6

What is new on ES6

Date post: 09-Jan-2017
Category:
Upload: huge
View: 954 times
Download: 0 times
Share this document with a friend
117
Transcript

ECMAScript 2015

Huge

1. What have changed

2. New features

Agenda

What have changed.

var IIFE

function () {} param = param || "default"

‘Hello ’ + myVar + ‘.'

callback hell

let { blocks }

() => function ( param = "default" )

`Hello ${myVar}.̀

promises

ES2015.ES5.

What have changed.

What have changed. 1. Let.

2. Blocks.

3. Arrow functions.

4. Default params.

5. String interpolation.

6. Promises.

Let.What have changed.

Name.Let.

In computer science, a “let” expression associates a function definition with a

restricted scope.

The “let” expression may also be defined in mathematics, where it

associates a Boolean condition with a restricted scope.

Scope.Let.

The “let” statement declares a block scope local variable.“Let” allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used.“Var” variables are limited in scope to the function statement.

Use ”let” to define variables limited in scope to the block.

“Var” isn’t dead."Let" will make the javascript engine create a new scope for each block that has a "let" variable in it.

Examples.Let.

Temporal dead zone.Let.

Live code example.

Blocks.What have changed.

History.Blocks.

Ideas of block structure were developed in the 1950s during the development of

the first autocodes, and were formalized in the Algol 58 and Algol 60 reports.

In computer programming, a block or code block is a section of code which is grouped together. Blocks consist of one or more declarations and statements.

Blocks narrow the lexical scope of variables, procedures and functions

declared in it, so that they do not conflict with variables having the same name

used elsewhere.

Other languages.Blocks.

Algol

Python

Examples.Blocks.

Arrow functions.What have changed.

About.Arrow functions.

Arrow functions are always anonymous.An arrow function expression has a shorter syntax compared to function expressions and lexically binds the "this" value.

Examples.Arrow functions.

Lexical "this".

Shorter functions.

Default params.What have changed.

String interpolation.What have changed.

Promises.What have changed.

About.Promises.

The Promise object is used for deferred and asynchronous computations.

A Promise represents an operation that hasn't completed yet, but is expected

in the future.

The cure.

Example.Promises.

Promise chain.

Gates of hell.

New

Const.New.

In computer programming, a constant is an identifier with an associated value

which cannot be altered.

The const declaration creates a read-only reference to a value.

It does not mean the value it holds is immutable.

Constants are block-scoped.

A constant cannot share its name with a function or a variable

in the same scope.

Useful methods.New.

Array Find.Useful methods.

The “find” method returns a single value in the array.

And the “filter” method?What is the difference?

Object Assign.Useful methods.

The "assign" method is used to copy all enumerable own properties from one or more source objects to a target object.

Cloning an object.

Merging objects.

Does he copy the methods too?

Spread / Rest.New.

Symbol.New.

A symbol is a unique and immutable data type.

Symbols are the same even when in other threads.

Symbol properties.

Iterator & Iterable.New.

The iterator protocol defines a standard way to produce

a sequence of values.

The Iterable protocol allows JavaScript objects to define or customize their

iteration behavior.

This is an iterator.

This is an iterable.

Can I create a custom iterator?

Generator.New.

Generators are functions which can be exited and later re-entered.

The “function*” declaration defines a generator function.

A generator returns an iterator.

Run .. Stop .. Run

Questions?


Recommended