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

JavaScript Beyond jQuery

JavaScript Beyond jQuery

WordCamp Milwaukee

Evan Solomon

June 08, 2013
Tweet

More Decks by Evan Solomon

Other Decks in Technology

Transcript

  1. var name = 'Evan Solomon', twitter = name .replace(/ /g,

    '') .replace(/^/, '@') .toLowerCase();
  2. var context = 'global', stuff = { context: 'object', show:

    function() { return this.context; } }; stuff.show(); // object
  3. var Thing = function() { this.context = 'instance'; this.show =

    function() { return this.context; }; }; thing = new Thing; thing.show(); // instance
  4. var context = 'global', stuff = { context: 'object', show:

    function() { return this.context; } }, ohnoes = stuff.show; ohnoes(); // global
  5. var context = 'the window', show = function() { return

    this.context; }; show.call(); // 'the window' show.call({context:'anything'}); // 'anything'
  6. var that = {context: 'safe'}, show = function() { return

    this.context; }, bound = function() { return show.apply(that); }; show(); // undefined bound(); // 'safe'
  7. var nums = [1, 2]; nums.slice === Array.prototype.slice // true

    nums.slice === nums.constructor.prototype.slice // true nums.constructor === Array // true
  8. var evan = new Person('Evan'), john = new Person('Alison'); Person.prototype.sayHi

    = function() { return 'I am ' + this.name; }; evan.sayHi(); // 'I am Evan' john.sayHi(); // 'I am Alison'
  9. var wordcamps = [ {place: 'Milwauke', when: 'today'}, {place: 'San

    Francisco', when: 'later'}, ]; _.pluck(wordcamps, 'when'); // ['today', 'later']
  10. var go = function() { return 'Be patient'; }, notYet

    = _.after(2, go); notYet(); // Undefined notYet(); // 'Be patient'
  11. var notYet = _.after(2, function() { return 'Be patient'; }

    ); notYet(); // Undefined notYet(); // 'Be patient'
  12. var http = require('http'), server = function (req, res) {

    res.end('Hello World!\n'); }; http.createServer(server) .listen(8080);