FCEyN Working at Kidozen ( ) www.kidozen.com Working with CoderHouse to build the Back End course Github: a0viedo Bitbucket: a0viedo Twitter: @a0viedo Pinterest: '' Instragram: '' ICQ: ''
founded in 1961 and dedicated to the standardization of Information and Communication Technology (ICT) and Consumer Electronics (CE). Ecma created a committee called TC39 ECMAScript in 2012 with the following purpose: Standardization of the general purpose, cross platform, vendor-neutral programming language ECMAScript. This includes the language syntax, semantics, and libraries and complementary technologies that support the language.
the specs? An unofficial HTML version of ECMAScript 6 (a.k.a. Next (a.k.a. Harmony)) working draft is being maintained by Mozilla . For specification drafts released by ECMA you can visit . here wiki.ecmascript.org 633 pages of pure love!
related feature in C#, Java 8 and CoffeeScript. Unlike functions, arrows share the same lexical this as their surrounding code. Arrow functions are always anonymous! Example: [1,2,3].forEach(function(x) { console.log(x + 1) }); // can be changed to [1,2,3].forEach(x => console.log(x + 1)); (a, b) => { //your code }
use of patterns to extract parts of an object. The latest ECMAScript 6 defines the grammar for destructuring assignment in Section 11.13.1. There are two different forms: array pattern and object pattern.
10, 2015]; //instead of var d = 21, m = 10, a = 2015; x = 3; y = 4; [x, y] = [y, x] // instead of temp = [y, x]; x = temp[0]; y = temp[1]; function now() { return [15, 5, 2014, 20, 0]; } var [d, m] = now(); // m = 15, d = 5 var [,,year] = now(); // no need to accept all elements
15, m: 5, y: 2014 }; } var { m: month, y: year } = today(); // month = 5, year = 2014 var document = { timestamp: 1400077764803, latitude: -8.137003, longitud function processDocument({ latitude: lat, longitude: long }) { // do something here }
The two most important work-arounds standards are CommonJS Modules (CJS): the popular implementation of this standard is Node.js modules Asynchronous Module Definition (AMD): The most popular implementation of this standard is RequireJS
module can be any file with Javascript in it. You can export a variable declaration, a function declaration or a class declaration using the export keyword. Suppose we have a calc.js file with this code: let notExported = 'abc'; export function multiply(x) { return x * MY_CONSTANT; } export const MY_CONSTANT = 7;
return x * MY_CONSTANT; } const MY_CONSTANT = 7; export { multiply, MY_CONSTANT }; You can rename while exporting: export { multiply as mult, MY_CONSTANT as ANOTHER_CONSTANT }; Re-exporting: You can re-export some exports of another module like this: export { sha-1 as sha-1 } from 'lib/crypto'; // re-exports only sha-1 export * from 'lib/crypto'; // or re-export everything
into main.js you could just write Main.js refers to calc.js through module ID 'calc' (string). The default interpretation of the module ID is a path relative to the importing module. Another option would be to import the module as an object: import { multiply } from 'calc'; console.log(multiply(3)); import 'calc' as c; console.log(c.multiply(3));
There are several projects that enables you to use ECMAScript 6 modules today: : write your modules using a subset of ECMAScript 6 (roughly: ECMAScript 5 + export + import), compile them to AMD or CommonJS modules. : polyfills the ECMAScript 6 module loader API on current browsers. other: (plugin for RequireJS), (transpiler) or TypeScript. ES6 Module Transpiler ES6 Module Loader require-hm Traceur
Hoban - https://github.com/lukehoban/es6features Bonus: - http://carnotaurus.philipcarney.com/post/3010984357/classes- versus-prototypes-some-philosophical-and 2ality on ES6 Ariya Hidayat on ES6 Nicholas C. Zakas on ES6 ES6 Features Classes and prototypes