Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fast Forward Javascript

Sho Kusano
October 16, 2012

Fast Forward Javascript

立ち止まってる暇なんてない。 CoffeeScript の紹介です。

Sho Kusano

October 16, 2012
Tweet

More Decks by Sho Kusano

Other Decks in Programming

Transcript

  1. Example Case: This binding var object = { name: 'obj',

    func: function(){ console.log(this.name); } } object.func(); // → obj var f = object.func; f(); // → undefined var other = {name: 'other', func: f}; other.func(); // → other
  2. Example Case: This Binding class Example name: 'obj' func: ()=>

    console.log @name object = new Example object.func() # → obj f = object.func f() # → obj other = { name: 'other' func: f } other.func() # → obj
  3. Example Case: Prototypical Object var Abstruct = function() { this.prop

    = 'property'; } Abstruct.prototype.func = function(){}; var Class = function() { } Class.prototype = {}; for(var method in Abstruct.prototype) { Class.prototype[method] = Abstruct.prototype[method]; }
  4. Example Case: Object forEach var object = { a: 1,

    b: 2, c: 3 } for(var key in object) { if(object.hasOwnProperty(key)) console.log(object[key]); }
  5. Example Case: Object forEach object = { a: 1 b:

    2, c: 3 } for key, val of object console.log val
  6. Many Features! Destructuring Assignment, Function binding, Embedded JavaScript, Switch/When/Else, Try/Catch/Finally,

    Chained Comparisons, String Interpolation, Block Strings, and Block Comments, Block Regular Expressions, Cake, and Cakefiles, "text/coffeescript" Script Tags