Nordic.js 2014 • Douglas Crockford - The Better Parts

By: Nordic.js

555   9   41807

Uploaded on 10/06/2014

Comments (4):

By gorkemyurt    2017-09-20

Douglas Crockford might have some answers for you; https://www.youtube.com/watch?v=PSGEjv3Tqo0.. It makes the developer favor inheritance over composition.

Original Thread

By Yaggo    2017-09-20

It's possible to write javascript without `this`, a style preferred e.g. by Douglas Crockford, explained in the video below.

https://www.youtube.com/watch?v=PSGEjv3Tqo0

I've also started to write my code mostly without `this`, `class` or `new`, not looking back.

Another related, highly recommend reading: https://medium.com/javascript-scene/the-two-pillars-of-javas...

Original Thread

By anonymous    2017-09-20

This is Douglas Crockford original source as it appears in his slides:

function constructor(spec) {
  let {member} = spec,
      {other} = other_constructor(spec),
      method = function () {
        // member, other, method, spec
      };
  return Object.freeze({
    method,
    other
  });
}

The following example is a more concrete version of Douglas Crockford's Object creation pattern 2014.

Douglas Crockford makes heavy use of ECMAScript 6 features like destructuring etc.!!

Start the code in node.js with following options (enable ES6):

node --harmony --harmony_destructuring demo.js

demo.js

// Douglas Crockford 2014 Object Creation
(function() {
  'use strict';

  function adress(spec) {

    let {
      street, city
    } = spec,
    logAdress = function() {
      console.log('Adress:', street, city);
    };
    return Object.freeze({
      logAdress
    });
  };

  function person(spec) {

    let {
      preName,
      name
    } = spec, {
      logAdress
    } = adress(spec),
      logPerson = function() {
        // member, other, method, spec
        console.log('Name: ', preName, name);
        logAdress();
      };
    return Object.freeze({
      logPerson,
      logAdress
    });
  };


  let myPerson = person({
    preName: 'Mike',
    name: 'Douglas',
    street: 'Newstreet',
    city: 'London'
  });

  myPerson.logPerson();
})();

According to Douglas Crockford’s talk, he avoids the use of:

  • new
  • Object.create
  • this !!!

Watch the original Crockford video: https://www.youtube.com/watch?v=PSGEjv3Tqo0

A good explanation for the Crockford Douglas Object Creation Pattern 2014 is this blog: https://weblogs.asp.net/bleroy/crockford%E2%80%99s-2014-object-creation-pattern

Original Thread

Recommended Books

    Popular Videos 1071

    Submit Your Video

    If you have some great dev videos to share, please fill out this form.