SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
ES6Le nouveau JavaScript
@cyrilletuzi
…
…
6
3
15
5
20
72
450
…
ECMAScript
Le point sur les standards
ECMAScript
● 1999 ES3
● 2009 ES5
● 2011 mise à jour 5.1
● Juin 2015 ES6 / ES2015, standard actuel
● 2016 ES7 / ES2016, déjà en cours
● 2017
● 2018…
www.ecma-international.org/publications/standards/Ecma-262.htm
JavaScript
● JavaScript moderne :
○ addEventListener (onclick)
○ querySelectorAll
○ DOMContentLoaded
○ classList...
● APIs "HTML5" gérées par le W3C
○ AJAX
○ géolocalisation
○ stockage local...
ES6
Les principales nouveautés
ES6 : bases
● Portée de bloc
let
● Constantes
const OPTION = 1;
● Template literal
`<p id="my-id">Je m'appelle ${name}</p>`;
● Itération
for (let value of arrayLike) {}
ES6 : paramètres
● Valeurs par défaut
function optional(param = "default value") {}
● Rest parameters
function rest(...params) {
params.forEach(function (value, index) {});
}
● Spread parameters
function spread(param1, param2) {}
var myParams = ['open', 'ska'];
spread(...myParams);
ES6 : arrow functions
● ES5 : problèmes de contexte
element.addEventListener('click', function () {
setTimeout(function () {
this.textContent = 'openska';
}, 2000);
});
● ES6 : arrow functions
element.addEventListener('click', function () {
setTimeout(() => {
this.textContent = 'openska';
}, 2000);
});
Asynchronicité
● Promises : simplification de l'asynchronicité
var p = new Promise();
p.then((result) => {}, (error) => {});
Promise.resolve(result);
Promise.reject(error);
Promise.all([p1, p2]).then((results) => {});
● Polyfill : github.com/jakearchibald/es6-promise
AJAX
● Fetch : simplification de l'AJAX
fetch('/openska-catalog.json').then(
(response) => response.json()
).then((json) => {}).catch();
● Polyfill : github.com/github/fetch
ES6
● Autres nouveautés ES6
○ Nouvelles méthodes pour String, Math, Array...
○ Collections : Set, Map
○ Destructuring
○ Proxy / Reflection
○ Générateurs...
hacks.mozilla.org/category/es6-in-depth/
ES6
La programmation orientée objet
ES6 : classes
● Classes : simplification de la programmation orientée objet
class User {
constructor(name) {
this.name = name;
}
helloWorld() {
return `Je m'appelle ${this.name}`;
}
}
ES6 : classes
● Héritage
class Editor extends User {
constructor(name) {
super(name);
}
}
● Méthodes statiques
class Utilities {
static filter() {}
}
ES6 : modules
● Import / export unique
export default User;
import User from 'module-user.js';
● Imports / exports multiples
export {User, Editor};
import {User, Editor} from 'module-user.js';
● Syntaxe simple proche de CommonJS.
● Possibilité de chargement asynchrone comme en AMD.
ES6 : modules
● Loader : System.js (ES6 + universel)
System.import('main.js');
github.com/systemjs/systemjs
● Spec en cours
ES7
● En prévision en ES7
○ Fonctions asynchrones
○ Observeurs
○ Propriétés dans les classes
○ Décorateurs / annotations
TypeScript
ES6 amélioré
TypeScript
● Avantages de TypeScript
○ ES6 amélioré
○ Typage fort
○ Surcouche optionnelle (≠ Dart)
○ Utilisé par défaut par Angular 2
Typage
● Typage fort
var catalog:string[] = ['JS', 'PHP'];
function meetup(participants:number):boolean {
return true;
}
TypeScript & ES6
● Classes ES6
○ + Propriétés
○ + Visibilité (public / privé)
○ + Classes abstraites
○ + Interfaces
ES6 en prod ?
Le point sur la compatibilité
Internet Explorer
● Good bye IE 6 & 7
○ Windows XP terminé depuis début 2014
○ jQuery 3 va les abandonner
● IE 8 en voie d'extinction (< 3%)
○ IE 11 Enterprise Mode, Firefox ESR, Chrome for Business
○ polyfill.io
● ES5 depuis IE 9
● Edge : premier en ES6
Compatibilité ES6
● Compatibilité ES6/7
kangax.github.io/compat-table/
● Compatibilité APIs "HTML5"
caniuse.com
Compilers ES6
● Traceur
○ Runtime pour optimiser
● Babel (ex es6to5)
○ Filtrage par fonctionnalité
● TypeScript
○ ES6 amélioré + typage fort
Adoption de l'ES6
● Ils utilisent déjà l'ES6 :
○ Nodejs
○ Angular 2
○ React
○ Meteor…
● Oui, l'ES6 est utilisable pour de la prod !
Coder en ES6
● Visual Studio Code
code.visualstudio.com
● Atom + plugin atom-typescript
atom.io
● Source maps pour le debug.
MERCI
@cyrilletuzi

Contenu connexe

Tendances

Les Promises en Javascript
Les Promises en JavascriptLes Promises en Javascript
Les Promises en JavascriptBenoit Zohar
 
Notions de base de JavaScript
Notions de base de JavaScriptNotions de base de JavaScript
Notions de base de JavaScriptKristen Le Liboux
 
Initiation au JavaScript
Initiation au JavaScriptInitiation au JavaScript
Initiation au JavaScriptStrasWeb
 
BackDay Xebia : Découvrez RxJava, le reactive programming
BackDay Xebia : Découvrez RxJava, le reactive programmingBackDay Xebia : Découvrez RxJava, le reactive programming
BackDay Xebia : Découvrez RxJava, le reactive programmingPublicis Sapient Engineering
 
Présentation Javascript à l'ESI (Alger)
Présentation Javascript à l'ESI (Alger)Présentation Javascript à l'ESI (Alger)
Présentation Javascript à l'ESI (Alger)Dr Samir A. ROUABHI
 

Tendances (8)

Javascript proprement
Javascript proprementJavascript proprement
Javascript proprement
 
Les Promises en Javascript
Les Promises en JavascriptLes Promises en Javascript
Les Promises en Javascript
 
Notions de base de JavaScript
Notions de base de JavaScriptNotions de base de JavaScript
Notions de base de JavaScript
 
Initiation au JavaScript
Initiation au JavaScriptInitiation au JavaScript
Initiation au JavaScript
 
Nouveautés de java 8
Nouveautés de java 8Nouveautés de java 8
Nouveautés de java 8
 
BackDay Xebia : Découvrez RxJava, le reactive programming
BackDay Xebia : Découvrez RxJava, le reactive programmingBackDay Xebia : Découvrez RxJava, le reactive programming
BackDay Xebia : Découvrez RxJava, le reactive programming
 
The Future of Javascript
The Future of JavascriptThe Future of Javascript
The Future of Javascript
 
Présentation Javascript à l'ESI (Alger)
Présentation Javascript à l'ESI (Alger)Présentation Javascript à l'ESI (Alger)
Présentation Javascript à l'ESI (Alger)
 

En vedette

immigration-detention-inquiry-report
immigration-detention-inquiry-reportimmigration-detention-inquiry-report
immigration-detention-inquiry-reportSarah Teather
 
Breaking the Cycle of Poverty: Community Based Organizations & Higher Education
Breaking the Cycle of Poverty: Community Based Organizations & Higher EducationBreaking the Cycle of Poverty: Community Based Organizations & Higher Education
Breaking the Cycle of Poverty: Community Based Organizations & Higher EducationUnited Way of Greater Greensboro
 
Crew Report - Jacotine Refit
Crew Report - Jacotine RefitCrew Report - Jacotine Refit
Crew Report - Jacotine RefitMalcolm Jacotine
 
History of genre
History of genre History of genre
History of genre M4SUD_123
 
NSACPlansBook_PizzaHut2015
NSACPlansBook_PizzaHut2015NSACPlansBook_PizzaHut2015
NSACPlansBook_PizzaHut2015Nikki Molkara
 
Santiago araujo 7 4
Santiago araujo 7 4Santiago araujo 7 4
Santiago araujo 7 4Santi Araujo
 
Arterki hss drill bit for metal or wood
Arterki hss drill bit for metal or wood Arterki hss drill bit for metal or wood
Arterki hss drill bit for metal or wood sally shen
 
Different between cnc and manual beads machine
Different between cnc and manual beads machineDifferent between cnc and manual beads machine
Different between cnc and manual beads machinesally shen
 
TSO Issue 12 - Crunching Numbers
TSO Issue 12 - Crunching NumbersTSO Issue 12 - Crunching Numbers
TSO Issue 12 - Crunching NumbersMalcolm Jacotine
 
TSR Issue 158 - Cracking the Code
TSR Issue 158 - Cracking the CodeTSR Issue 158 - Cracking the Code
TSR Issue 158 - Cracking the CodeMalcolm Jacotine
 
Crew Report - Jacotine Mentoring
Crew Report - Jacotine MentoringCrew Report - Jacotine Mentoring
Crew Report - Jacotine MentoringMalcolm Jacotine
 
Binary Trading Australia
Binary Trading AustraliaBinary Trading Australia
Binary Trading AustraliaBrodie Capel
 
Crew Report - Jacotine Interview 2
Crew Report - Jacotine Interview 2Crew Report - Jacotine Interview 2
Crew Report - Jacotine Interview 2Malcolm Jacotine
 

En vedette (17)

immigration-detention-inquiry-report
immigration-detention-inquiry-reportimmigration-detention-inquiry-report
immigration-detention-inquiry-report
 
Karen ps
Karen psKaren ps
Karen ps
 
Breaking the Cycle of Poverty: Community Based Organizations & Higher Education
Breaking the Cycle of Poverty: Community Based Organizations & Higher EducationBreaking the Cycle of Poverty: Community Based Organizations & Higher Education
Breaking the Cycle of Poverty: Community Based Organizations & Higher Education
 
Crew Report - Jacotine Refit
Crew Report - Jacotine RefitCrew Report - Jacotine Refit
Crew Report - Jacotine Refit
 
LinkedIn Resume
LinkedIn ResumeLinkedIn Resume
LinkedIn Resume
 
History of genre
History of genre History of genre
History of genre
 
NSACPlansBook_PizzaHut2015
NSACPlansBook_PizzaHut2015NSACPlansBook_PizzaHut2015
NSACPlansBook_PizzaHut2015
 
The book
The bookThe book
The book
 
Santiago araujo 7 4
Santiago araujo 7 4Santiago araujo 7 4
Santiago araujo 7 4
 
Arterki hss drill bit for metal or wood
Arterki hss drill bit for metal or wood Arterki hss drill bit for metal or wood
Arterki hss drill bit for metal or wood
 
Different between cnc and manual beads machine
Different between cnc and manual beads machineDifferent between cnc and manual beads machine
Different between cnc and manual beads machine
 
TSO Issue 12 - Crunching Numbers
TSO Issue 12 - Crunching NumbersTSO Issue 12 - Crunching Numbers
TSO Issue 12 - Crunching Numbers
 
TSR Issue 158 - Cracking the Code
TSR Issue 158 - Cracking the CodeTSR Issue 158 - Cracking the Code
TSR Issue 158 - Cracking the Code
 
venkatesh
venkateshvenkatesh
venkatesh
 
Crew Report - Jacotine Mentoring
Crew Report - Jacotine MentoringCrew Report - Jacotine Mentoring
Crew Report - Jacotine Mentoring
 
Binary Trading Australia
Binary Trading AustraliaBinary Trading Australia
Binary Trading Australia
 
Crew Report - Jacotine Interview 2
Crew Report - Jacotine Interview 2Crew Report - Jacotine Interview 2
Crew Report - Jacotine Interview 2
 

Similaire à ES6, le futur de Javascript

I le langage java d'una manière avancée introduction
I  le langage java d'una manière avancée introductionI  le langage java d'una manière avancée introduction
I le langage java d'una manière avancée introductionsabrine_hamdi
 
Présentation de ECMAScript 6
Présentation de ECMAScript 6Présentation de ECMAScript 6
Présentation de ECMAScript 6Julien CROUZET
 
Electron, une alternative intéressante ? par Florent MOIGNARD
Electron, une alternative intéressante ? par Florent MOIGNARDElectron, une alternative intéressante ? par Florent MOIGNARD
Electron, une alternative intéressante ? par Florent MOIGNARDLa Cuisine du Web
 
Monitoring d'applications/environnements PHP : APM et Pinba
Monitoring d'applications/environnements PHP : APM et PinbaMonitoring d'applications/environnements PHP : APM et Pinba
Monitoring d'applications/environnements PHP : APM et PinbaIdaf_1er
 
Rouabhi algiers meetup
Rouabhi algiers meetupRouabhi algiers meetup
Rouabhi algiers meetupSamir Rouabhi
 
Enib cours c.a.i. web - séance #5 : scala play! framework
Enib   cours c.a.i. web - séance #5 : scala play! frameworkEnib   cours c.a.i. web - séance #5 : scala play! framework
Enib cours c.a.i. web - séance #5 : scala play! frameworkHoracio Gonzalez
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !Paris Salesforce Developer Group
 
Introduction à CakePHP
Introduction à CakePHPIntroduction à CakePHP
Introduction à CakePHPPierre MARTIN
 
C2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partieC2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partieLoic Yon
 
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018Loic Yon
 
LLVM, clang & c++
LLVM, clang & c++LLVM, clang & c++
LLVM, clang & c++cppfrug
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoftdavrous
 
GDG Rennes - Bootcamp Initiation Android - Théorie
GDG Rennes - Bootcamp Initiation Android -  ThéorieGDG Rennes - Bootcamp Initiation Android -  Théorie
GDG Rennes - Bootcamp Initiation Android - ThéorieHoracio Gonzalez
 
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdf
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdfdevoxx 2022 - 10 ans de Devoxx FR et de Java.pdf
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdfJean-Michel Doudoux
 
TypeScript for dummies
TypeScript for dummiesTypeScript for dummies
TypeScript for dummiesMicrosoft
 
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...XavierPestel
 
Enib cours c.a.i. web - séance #6 : introduction à node js
Enib   cours c.a.i. web - séance #6 : introduction à node jsEnib   cours c.a.i. web - séance #6 : introduction à node js
Enib cours c.a.i. web - séance #6 : introduction à node jsHoracio Gonzalez
 

Similaire à ES6, le futur de Javascript (20)

I le langage java d'una manière avancée introduction
I  le langage java d'una manière avancée introductionI  le langage java d'una manière avancée introduction
I le langage java d'una manière avancée introduction
 
Présentation de ECMAScript 6
Présentation de ECMAScript 6Présentation de ECMAScript 6
Présentation de ECMAScript 6
 
EcmaScript
EcmaScriptEcmaScript
EcmaScript
 
Electron, une alternative intéressante ? par Florent MOIGNARD
Electron, une alternative intéressante ? par Florent MOIGNARDElectron, une alternative intéressante ? par Florent MOIGNARD
Electron, une alternative intéressante ? par Florent MOIGNARD
 
Monitoring d'applications/environnements PHP : APM et Pinba
Monitoring d'applications/environnements PHP : APM et PinbaMonitoring d'applications/environnements PHP : APM et Pinba
Monitoring d'applications/environnements PHP : APM et Pinba
 
Rouabhi algiers meetup
Rouabhi algiers meetupRouabhi algiers meetup
Rouabhi algiers meetup
 
Enib cours c.a.i. web - séance #5 : scala play! framework
Enib   cours c.a.i. web - séance #5 : scala play! frameworkEnib   cours c.a.i. web - séance #5 : scala play! framework
Enib cours c.a.i. web - séance #5 : scala play! framework
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
 
Cours JavaScript
Cours JavaScriptCours JavaScript
Cours JavaScript
 
Introduction à CakePHP
Introduction à CakePHPIntroduction à CakePHP
Introduction à CakePHP
 
C2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partieC2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partie
 
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018
Java - Support etudiant - Tronc Commun Deuxième année ISIMA - 2018
 
LLVM, clang & c++
LLVM, clang & c++LLVM, clang & c++
LLVM, clang & c++
 
Algo poo ts
Algo poo tsAlgo poo ts
Algo poo ts
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoft
 
GDG Rennes - Bootcamp Initiation Android - Théorie
GDG Rennes - Bootcamp Initiation Android -  ThéorieGDG Rennes - Bootcamp Initiation Android -  Théorie
GDG Rennes - Bootcamp Initiation Android - Théorie
 
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdf
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdfdevoxx 2022 - 10 ans de Devoxx FR et de Java.pdf
devoxx 2022 - 10 ans de Devoxx FR et de Java.pdf
 
TypeScript for dummies
TypeScript for dummiesTypeScript for dummies
TypeScript for dummies
 
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
 
Enib cours c.a.i. web - séance #6 : introduction à node js
Enib   cours c.a.i. web - séance #6 : introduction à node jsEnib   cours c.a.i. web - séance #6 : introduction à node js
Enib cours c.a.i. web - séance #6 : introduction à node js
 

ES6, le futur de Javascript

  • 4.
  • 5. ECMAScript Le point sur les standards
  • 6. ECMAScript ● 1999 ES3 ● 2009 ES5 ● 2011 mise à jour 5.1 ● Juin 2015 ES6 / ES2015, standard actuel ● 2016 ES7 / ES2016, déjà en cours ● 2017 ● 2018… www.ecma-international.org/publications/standards/Ecma-262.htm
  • 7. JavaScript ● JavaScript moderne : ○ addEventListener (onclick) ○ querySelectorAll ○ DOMContentLoaded ○ classList... ● APIs "HTML5" gérées par le W3C ○ AJAX ○ géolocalisation ○ stockage local...
  • 9. ES6 : bases ● Portée de bloc let ● Constantes const OPTION = 1; ● Template literal `<p id="my-id">Je m'appelle ${name}</p>`; ● Itération for (let value of arrayLike) {}
  • 10. ES6 : paramètres ● Valeurs par défaut function optional(param = "default value") {} ● Rest parameters function rest(...params) { params.forEach(function (value, index) {}); } ● Spread parameters function spread(param1, param2) {} var myParams = ['open', 'ska']; spread(...myParams);
  • 11. ES6 : arrow functions ● ES5 : problèmes de contexte element.addEventListener('click', function () { setTimeout(function () { this.textContent = 'openska'; }, 2000); }); ● ES6 : arrow functions element.addEventListener('click', function () { setTimeout(() => { this.textContent = 'openska'; }, 2000); });
  • 12. Asynchronicité ● Promises : simplification de l'asynchronicité var p = new Promise(); p.then((result) => {}, (error) => {}); Promise.resolve(result); Promise.reject(error); Promise.all([p1, p2]).then((results) => {}); ● Polyfill : github.com/jakearchibald/es6-promise
  • 13. AJAX ● Fetch : simplification de l'AJAX fetch('/openska-catalog.json').then( (response) => response.json() ).then((json) => {}).catch(); ● Polyfill : github.com/github/fetch
  • 14. ES6 ● Autres nouveautés ES6 ○ Nouvelles méthodes pour String, Math, Array... ○ Collections : Set, Map ○ Destructuring ○ Proxy / Reflection ○ Générateurs... hacks.mozilla.org/category/es6-in-depth/
  • 16. ES6 : classes ● Classes : simplification de la programmation orientée objet class User { constructor(name) { this.name = name; } helloWorld() { return `Je m'appelle ${this.name}`; } }
  • 17. ES6 : classes ● Héritage class Editor extends User { constructor(name) { super(name); } } ● Méthodes statiques class Utilities { static filter() {} }
  • 18. ES6 : modules ● Import / export unique export default User; import User from 'module-user.js'; ● Imports / exports multiples export {User, Editor}; import {User, Editor} from 'module-user.js'; ● Syntaxe simple proche de CommonJS. ● Possibilité de chargement asynchrone comme en AMD.
  • 19. ES6 : modules ● Loader : System.js (ES6 + universel) System.import('main.js'); github.com/systemjs/systemjs ● Spec en cours
  • 20. ES7 ● En prévision en ES7 ○ Fonctions asynchrones ○ Observeurs ○ Propriétés dans les classes ○ Décorateurs / annotations
  • 22. TypeScript ● Avantages de TypeScript ○ ES6 amélioré ○ Typage fort ○ Surcouche optionnelle (≠ Dart) ○ Utilisé par défaut par Angular 2
  • 23. Typage ● Typage fort var catalog:string[] = ['JS', 'PHP']; function meetup(participants:number):boolean { return true; }
  • 24. TypeScript & ES6 ● Classes ES6 ○ + Propriétés ○ + Visibilité (public / privé) ○ + Classes abstraites ○ + Interfaces
  • 25. ES6 en prod ? Le point sur la compatibilité
  • 26. Internet Explorer ● Good bye IE 6 & 7 ○ Windows XP terminé depuis début 2014 ○ jQuery 3 va les abandonner ● IE 8 en voie d'extinction (< 3%) ○ IE 11 Enterprise Mode, Firefox ESR, Chrome for Business ○ polyfill.io ● ES5 depuis IE 9 ● Edge : premier en ES6
  • 27. Compatibilité ES6 ● Compatibilité ES6/7 kangax.github.io/compat-table/ ● Compatibilité APIs "HTML5" caniuse.com
  • 28. Compilers ES6 ● Traceur ○ Runtime pour optimiser ● Babel (ex es6to5) ○ Filtrage par fonctionnalité ● TypeScript ○ ES6 amélioré + typage fort
  • 29. Adoption de l'ES6 ● Ils utilisent déjà l'ES6 : ○ Nodejs ○ Angular 2 ○ React ○ Meteor… ● Oui, l'ES6 est utilisable pour de la prod !
  • 30. Coder en ES6 ● Visual Studio Code code.visualstudio.com ● Atom + plugin atom-typescript atom.io ● Source maps pour le debug.