Outils pour utilisateurs

Outils du site


web:javascript:es6:toc

Ceci est une ancienne révision du document !


Itérateurs

var cars = ['Toyota', 'Ferrari', 'BMW'];
 
// forEach() de ES5 et ES6
cars.forEach(function(car) {
    console.log(car);
)};
 
// Dans ES6, opérateur 'of'
for(var value of cars) {
  console.log(value);
}

Modules

On peut exporter des fonctions d'un module, par exemple hello() du module person:

// Fichier: lib/person.js
 
module 'person' {
    export function hello(name) {
        return name;
    }
}

Ensuite, on peut importer hello() :

// Fichier: app.js
 
import { hello } from 'person';
web/javascript/es6/toc.1457280932.txt.gz · Dernière modification : 2022/02/02 00:43 (modification externe)