SlideShare a Scribd company logo
2013




JavaScript revolution
New syntax ( sugar of course! )
              &
      standard library
Who I am?


       Kamil Gałuszka
Django / Objective-C / Python World
JavaScript is only a hobby (for now)




       @galuszkak


       http://solution4future.com
Introduction & Inspiration
JavaScript, JS, ECMAScript, ES

● ECMAScript 3 ( 1999 )

● ECMAScript 4 ( incompatible with third version
  2005 )

● ECMAScript 5 ( 2009 )

● ECMAScript 5.1 ( 2011 )

● TC39 - Committee for Standardization
Funny Facts


● ES 5.1 standard == 243 pages

● JavaScript: The Definitive Guide by David
  Flanagan (6th edition)== 1078 pages

● Draft of standard ES 6.0 == 421 pages

● JavaScript: The Definitive Guide by David
  Flanagan (7th edition)== ? pages ;)
Warm Up

false == "0"               false === "0"
false == "false"           null === undefined
null == undefined          "" === 0
"" == 0
NaN === NaN
6.toString();
" nt" == 0;
obj = {x:10, y:20};
delete obj.y;
obj.y == null              obj.y === null
obj.y == undefined         obj.y === undefined
ES.Next vs ES.Harmony




        ES.Next === ECMAScript 6


ES 6 is fully compatible with ES5 (strict mode)


ES.Harmony in next versions of ECMAScript
Block Scope

Two new significant keywords:
let         lock scoped variable
const       read-only variable. (couldn't be hided by other variable etc.)

Typical problem in ES 5
    var result = [];
    for (var length = 10; length--;){
       var len = length;
       result[len] = function(){ return len; }
    }
    result[5]() // 0
    result[2]() // 0

WHY?
Block Scope
Solution ES 5

   var result = [];
   for (var length = 10; length--;){
      var len = length;
      result[len] = (function(dlugosc){
           return function(){
               return dlugosc;
           }
       })(len)
   }
   result[5]() // 5
   result[2]() // 2

use closure
Block Scope



Solution ES 6 (Cleaner, nicer, AWESOME!)

   var result = [];
   for (var length = 10; length--;){
      let len = length;
      result[len] = function(){ return len;}
   }
   result[5]() // 5
   result[2]() // 2
Shorthand Object Literals



ES 5 version:              ES 6 version:

var cat = "Molly";         var cat = "Molly";
var dog = "Rex";           var dog = "Rex";
var pets = {               var pets = {cat,dog}
    'cat': cat,
    'dog': dog,
}
Shorthand Object Literals


function Animal(name){
     this.name = name;
     this.age = 0;
}

Animal.prototype = {
  roar(text){
  //old version was function roar(text)
     return `Animal ${this.name}
  roars:${text}` // template syntax
  }
}
Destructing Assignments
      (extraction from objects, swap variables)




var {parse, stringify} = JSON;

var [, areaCode, local] = /^(d{3})-(d{3}-d
{4})$/.exec("048-032-7777");

[left, right] = [right, left];
Destructuring Nested Objects
var poets = [{
        "name": "T.S. Eliot",
        "works": [{
                 "title": "The Love Song",
                 "date": 1915
            }, {
                 "title": "Rhapsody",
                 "date": 1917
            }]
   }, {
        "name": "Ezra Pound",
        "works": [{
                 "title": "Ripostes",
                 "date": 1912
            }]
   }];
Destructuring Nested Objects




ES 5 VERSION ( really hard to remember )

var author = poets[0]['name'];
var title = poets[0]['works'][1]['title'];
var date = poets[0]['works'][1]['date'];
Destructuring Nested Objects


ES 6 version (AWESOME !)
  var [{'name': author, 'works': [, {title,
  date}]}] = poets;
  // Select first author and his second book
  and store it in variables author, title, date

  `"${title}", by ${author}, was published in
  ${date}.`
  // Template creating string from this
  variables.

Rhapsody, by T.S. Eliot, was published in 1917
Default parameters


// ES 5
function Person(name, age){
   this.name = name || "Anonim";
   this.age = age || 0;
}

// ES 6
function Person(name="Anonim", age=0)
{
   this.name = name;
  this.age = 0;
}
...rest parameters

js>function f(a, b, ...r) {
   print(Array.isArray(r));
   return r.concat(a, b);
}
js>f(1, 2)
true
[1, 2]
js>f(1, 2, 3)
true
[3, 1, 2]
js>f(1, 2, 3, 4, 5)
true
[3, 4, 5, 1, 2]
...spread

//ES 5 merging array
js> var a = [1, 2]
[3, 4, 5]
js> var b = [3, 4, 5]
[1, 2]
js> a = a.concat(b)
[1, 2, 3, 4, 5]


//ES 6 merging array (AWESOME!)
js> var a = [3, 4, 5]
[3, 4, 5]
js> var b = [1, 2, ...a]
[1, 2, 3, 4, 5]
Array Comprehensions




var arr =
[ x for (x of a) if (x.color === ‘blue’) ]

var arr = [ square(x) for (x of [1,2,3,4,5]) ]




                     Example by Addy Osmani http://addyosmani.com/blog/a-few-new-thin
                     to-javascript/
Modules




module Car {
  // import …
  // export …
}




       Example by Addy Osmani http://addyosmani.com/blog/a-few-new-
       things-coming-to-javascript/
Modules

module Car {
   // Internal
   var licensePlateNo = '556-343';
   // External
   export function drive(speed, direction) {
     console.log('details:', speed, direction);
   }
   export module engine{
     export function check() { }
   }
};
                     Example by Addy Osmani http://addyosmani.com/blog/a-few-new-
                     things-coming-to-javascript/
Imports
      (Yes! YES! No requirejs or AMD needed)




import       "crypto"       as       crypto;
import { encrypt, decrypt } from "crypto";
import { encrypt: enc } from "crypto";

import {drive, engine} from Car;




                        Example by Addy Osmani http://addyosmani.com/blog/a-few-new-
                        things-coming-to-javascript/
Classes
module widgets {
  // ...
  class DropDownButton extends Widget {
    constructor(attributes) {
      super(attributes);
      this.buildUI();
    }
    buildUI() {
      this.domNode.onclick = function(){
         // ...
      };
    }
  }
                      Example by Addy Osmani http://addyosmani.com/blog/a-few-new-
}                     things-coming-to-javascript/
Classes
var widgets = (function(global) {
  function DropDownButton(attributes) {
    Widget.call(this, attributes);
    this.buildUI();
  }
  DropDownButton.prototype = Object.create
(Widget.prototype, {
    constructor: { value: DropDownButton },
    buildUI:     {
      value: function(e) {
        this.domNode.onclick = function(e) {
          // ...
        }
                     Example by Addy Osmani http://addyosmani.com/blog/a-few-new-
}}})})(this);        things-coming-to-javascript/
Compatibility Matrix




http://kangax.github.com/es5-compat-table/es6/
Thanks to...



Douglas Crockford http://javascript.crockford.com/

Kit Cambridge http://kitcambridge.be/
(His speech: http://www.youtube.com/watch?v=Dt0f2XdvriQ)

TC39

Addy Osmani http://addyosmani.com/blog/a-few-new-things-
coming-to-javascript/

More Related Content

What's hot (20)

PDF
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
PPTX
ES6 in Real Life
Domenic Denicola
 
PDF
ES6 - Next Generation Javascript
RameshNair6
 
ODP
ES6 PPT FOR 2016
Manoj Kumar
 
ODP
EcmaScript 6
Manoj Kumar
 
PDF
JavaScript ES6
Leo Hernandez
 
PDF
What's New in ES6 for Web Devs
Rami Sayar
 
PDF
Proxies are Awesome!
Brendan Eich
 
PPTX
ES6: Features + Rails
Santosh Wadghule
 
PPTX
Async Frontiers
Domenic Denicola
 
KEY
Alfresco the clojure way
Carlo Sciolla
 
ZIP
Oral presentation v2
Yeqi He
 
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
PPTX
Advanced JavaScript
Mahmoud Tolba
 
PDF
Introduction of ES2015
Nakajima Shigeru
 
PDF
LetSwift RxSwift 시작하기
Wanbok Choi
 
PDF
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
Wanbok Choi
 
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
PDF
How to Clone Flappy Bird in Swift
Giordano Scalzo
 
PDF
Planet-HTML5-Game-Engine Javascript Performance Enhancement
up2soul
 
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
ES6 in Real Life
Domenic Denicola
 
ES6 - Next Generation Javascript
RameshNair6
 
ES6 PPT FOR 2016
Manoj Kumar
 
EcmaScript 6
Manoj Kumar
 
JavaScript ES6
Leo Hernandez
 
What's New in ES6 for Web Devs
Rami Sayar
 
Proxies are Awesome!
Brendan Eich
 
ES6: Features + Rails
Santosh Wadghule
 
Async Frontiers
Domenic Denicola
 
Alfresco the clojure way
Carlo Sciolla
 
Oral presentation v2
Yeqi He
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Advanced JavaScript
Mahmoud Tolba
 
Introduction of ES2015
Nakajima Shigeru
 
LetSwift RxSwift 시작하기
Wanbok Choi
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
Wanbok Choi
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
How to Clone Flappy Bird in Swift
Giordano Scalzo
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
up2soul
 

Viewers also liked (20)

PDF
ES6: The Awesome Parts
Domenic Denicola
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PDF
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
PPTX
Promises, Promises
Domenic Denicola
 
PDF
JavaScript 1.5 to 2.0 (TomTom)
jeresig
 
PDF
JavaScript Promises
Tomasz Bak
 
PPTX
Real World Windows 8 Apps in JavaScript
Domenic Denicola
 
PPTX
ES6 is Nigh
Domenic Denicola
 
PDF
JavaScript im Jahr 2016
Christian Kaltepoth
 
PPTX
Creating Truly RESTful APIs
Domenic Denicola
 
PPTX
The Final Frontier
Domenic Denicola
 
PPTX
Client-Side Packages
Domenic Denicola
 
PPTX
JavaScript Promises
L&T Technology Services Limited
 
PPTX
JavaScript on the Desktop
Domenic Denicola
 
PDF
Boom! Promises/A+ Was Born
Domenic Denicola
 
PPSX
Webpack & EcmaScript 6 (Webelement #32)
srigi
 
PPTX
Domains!
Domenic Denicola
 
PPTX
The jsdom
Domenic Denicola
 
PPTX
The State of JavaScript (2015)
Domenic Denicola
 
ES6: The Awesome Parts
Domenic Denicola
 
The New JavaScript: ES6
Rob Eisenberg
 
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
Promises, Promises
Domenic Denicola
 
JavaScript 1.5 to 2.0 (TomTom)
jeresig
 
JavaScript Promises
Tomasz Bak
 
Real World Windows 8 Apps in JavaScript
Domenic Denicola
 
ES6 is Nigh
Domenic Denicola
 
JavaScript im Jahr 2016
Christian Kaltepoth
 
Creating Truly RESTful APIs
Domenic Denicola
 
The Final Frontier
Domenic Denicola
 
Client-Side Packages
Domenic Denicola
 
JavaScript Promises
L&T Technology Services Limited
 
JavaScript on the Desktop
Domenic Denicola
 
Boom! Promises/A+ Was Born
Domenic Denicola
 
Webpack & EcmaScript 6 (Webelement #32)
srigi
 
The jsdom
Domenic Denicola
 
The State of JavaScript (2015)
Domenic Denicola
 
Ad

Similar to JavaScript - new features in ECMAScript 6 (20)

PPTX
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPTX
Getting started with ES6
Nitay Neeman
 
PDF
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
PPTX
ES6 - JavaCro 2016
Nenad Pecanac
 
PDF
JavaScript in 2016
Codemotion
 
PPTX
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
PPTX
ES6 and BEYOND
Brian Patterson
 
PDF
ES6: The future is now
Sebastiano Armeli
 
PDF
Fitc whats new in es6 for web devs
FITC
 
PPTX
Getting started with ES6 : Future of javascript
Mohd Saeed
 
PDF
ECMAScript 6 new features
GephenSG
 
PDF
ECMAScript 6 Review
Sperasoft
 
PPTX
Living in harmony - a brief into to ES6
Richard Leland
 
PDF
Workshop 10: ECMAScript 6
Visual Engineering
 
PDF
Introduction to web programming for java and c# programmers by @drpicox
David Rodenas
 
PPTX
Introduction to es6
NexThoughts Technologies
 
PDF
ESCMAScript 6: Get Ready For The Future. Now
Krzysztof Szafranek
 
PDF
The Future of JavaScript (Ajax Exp '07)
jeresig
 
PDF
Javascript
Vlad Ifrim
 
PPTX
Understanding ECMA Script 6 Javascript by Gaurav Khurana
Gaurav Khurana
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Getting started with ES6
Nitay Neeman
 
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
ES6 - JavaCro 2016
Nenad Pecanac
 
JavaScript in 2016
Codemotion
 
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
ES6 and BEYOND
Brian Patterson
 
ES6: The future is now
Sebastiano Armeli
 
Fitc whats new in es6 for web devs
FITC
 
Getting started with ES6 : Future of javascript
Mohd Saeed
 
ECMAScript 6 new features
GephenSG
 
ECMAScript 6 Review
Sperasoft
 
Living in harmony - a brief into to ES6
Richard Leland
 
Workshop 10: ECMAScript 6
Visual Engineering
 
Introduction to web programming for java and c# programmers by @drpicox
David Rodenas
 
Introduction to es6
NexThoughts Technologies
 
ESCMAScript 6: Get Ready For The Future. Now
Krzysztof Szafranek
 
The Future of JavaScript (Ajax Exp '07)
jeresig
 
Javascript
Vlad Ifrim
 
Understanding ECMA Script 6 Javascript by Gaurav Khurana
Gaurav Khurana
 
Ad

Recently uploaded (20)

PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 

JavaScript - new features in ECMAScript 6

  • 1. 2013 JavaScript revolution New syntax ( sugar of course! ) & standard library
  • 2. Who I am? Kamil Gałuszka Django / Objective-C / Python World JavaScript is only a hobby (for now) @galuszkak http://solution4future.com
  • 4. JavaScript, JS, ECMAScript, ES ● ECMAScript 3 ( 1999 ) ● ECMAScript 4 ( incompatible with third version 2005 ) ● ECMAScript 5 ( 2009 ) ● ECMAScript 5.1 ( 2011 ) ● TC39 - Committee for Standardization
  • 5. Funny Facts ● ES 5.1 standard == 243 pages ● JavaScript: The Definitive Guide by David Flanagan (6th edition)== 1078 pages ● Draft of standard ES 6.0 == 421 pages ● JavaScript: The Definitive Guide by David Flanagan (7th edition)== ? pages ;)
  • 6. Warm Up false == "0" false === "0" false == "false" null === undefined null == undefined "" === 0 "" == 0 NaN === NaN 6.toString(); " nt" == 0; obj = {x:10, y:20}; delete obj.y; obj.y == null obj.y === null obj.y == undefined obj.y === undefined
  • 7. ES.Next vs ES.Harmony ES.Next === ECMAScript 6 ES 6 is fully compatible with ES5 (strict mode) ES.Harmony in next versions of ECMAScript
  • 8. Block Scope Two new significant keywords: let lock scoped variable const read-only variable. (couldn't be hided by other variable etc.) Typical problem in ES 5 var result = []; for (var length = 10; length--;){ var len = length; result[len] = function(){ return len; } } result[5]() // 0 result[2]() // 0 WHY?
  • 9. Block Scope Solution ES 5 var result = []; for (var length = 10; length--;){ var len = length; result[len] = (function(dlugosc){ return function(){ return dlugosc; } })(len) } result[5]() // 5 result[2]() // 2 use closure
  • 10. Block Scope Solution ES 6 (Cleaner, nicer, AWESOME!) var result = []; for (var length = 10; length--;){ let len = length; result[len] = function(){ return len;} } result[5]() // 5 result[2]() // 2
  • 11. Shorthand Object Literals ES 5 version: ES 6 version: var cat = "Molly"; var cat = "Molly"; var dog = "Rex"; var dog = "Rex"; var pets = { var pets = {cat,dog} 'cat': cat, 'dog': dog, }
  • 12. Shorthand Object Literals function Animal(name){ this.name = name; this.age = 0; } Animal.prototype = { roar(text){ //old version was function roar(text) return `Animal ${this.name} roars:${text}` // template syntax } }
  • 13. Destructing Assignments (extraction from objects, swap variables) var {parse, stringify} = JSON; var [, areaCode, local] = /^(d{3})-(d{3}-d {4})$/.exec("048-032-7777"); [left, right] = [right, left];
  • 14. Destructuring Nested Objects var poets = [{ "name": "T.S. Eliot", "works": [{ "title": "The Love Song", "date": 1915 }, { "title": "Rhapsody", "date": 1917 }] }, { "name": "Ezra Pound", "works": [{ "title": "Ripostes", "date": 1912 }] }];
  • 15. Destructuring Nested Objects ES 5 VERSION ( really hard to remember ) var author = poets[0]['name']; var title = poets[0]['works'][1]['title']; var date = poets[0]['works'][1]['date'];
  • 16. Destructuring Nested Objects ES 6 version (AWESOME !) var [{'name': author, 'works': [, {title, date}]}] = poets; // Select first author and his second book and store it in variables author, title, date `"${title}", by ${author}, was published in ${date}.` // Template creating string from this variables. Rhapsody, by T.S. Eliot, was published in 1917
  • 17. Default parameters // ES 5 function Person(name, age){ this.name = name || "Anonim"; this.age = age || 0; } // ES 6 function Person(name="Anonim", age=0) { this.name = name; this.age = 0; }
  • 18. ...rest parameters js>function f(a, b, ...r) { print(Array.isArray(r)); return r.concat(a, b); } js>f(1, 2) true [1, 2] js>f(1, 2, 3) true [3, 1, 2] js>f(1, 2, 3, 4, 5) true [3, 4, 5, 1, 2]
  • 19. ...spread //ES 5 merging array js> var a = [1, 2] [3, 4, 5] js> var b = [3, 4, 5] [1, 2] js> a = a.concat(b) [1, 2, 3, 4, 5] //ES 6 merging array (AWESOME!) js> var a = [3, 4, 5] [3, 4, 5] js> var b = [1, 2, ...a] [1, 2, 3, 4, 5]
  • 20. Array Comprehensions var arr = [ x for (x of a) if (x.color === ‘blue’) ] var arr = [ square(x) for (x of [1,2,3,4,5]) ] Example by Addy Osmani http://addyosmani.com/blog/a-few-new-thin to-javascript/
  • 21. Modules module Car { // import … // export … } Example by Addy Osmani http://addyosmani.com/blog/a-few-new- things-coming-to-javascript/
  • 22. Modules module Car { // Internal var licensePlateNo = '556-343'; // External export function drive(speed, direction) { console.log('details:', speed, direction); } export module engine{ export function check() { } } }; Example by Addy Osmani http://addyosmani.com/blog/a-few-new- things-coming-to-javascript/
  • 23. Imports (Yes! YES! No requirejs or AMD needed) import "crypto" as crypto; import { encrypt, decrypt } from "crypto"; import { encrypt: enc } from "crypto"; import {drive, engine} from Car; Example by Addy Osmani http://addyosmani.com/blog/a-few-new- things-coming-to-javascript/
  • 24. Classes module widgets { // ... class DropDownButton extends Widget { constructor(attributes) { super(attributes); this.buildUI(); } buildUI() { this.domNode.onclick = function(){ // ... }; } } Example by Addy Osmani http://addyosmani.com/blog/a-few-new- } things-coming-to-javascript/
  • 25. Classes var widgets = (function(global) { function DropDownButton(attributes) { Widget.call(this, attributes); this.buildUI(); } DropDownButton.prototype = Object.create (Widget.prototype, { constructor: { value: DropDownButton }, buildUI: { value: function(e) { this.domNode.onclick = function(e) { // ... } Example by Addy Osmani http://addyosmani.com/blog/a-few-new- }}})})(this); things-coming-to-javascript/
  • 27. Thanks to... Douglas Crockford http://javascript.crockford.com/ Kit Cambridge http://kitcambridge.be/ (His speech: http://www.youtube.com/watch?v=Dt0f2XdvriQ) TC39 Addy Osmani http://addyosmani.com/blog/a-few-new-things- coming-to-javascript/