Giter Club home page Giter Club logo

Comments (6)

neojski avatar neojski commented on June 3, 2024

In fact, it's not even working as config was never defined.

from essential-js-design-patterns.

addyosmani avatar addyosmani commented on June 3, 2024

Confirmed. Looking into this now.

from essential-js-design-patterns.

addyosmani avatar addyosmani commented on June 3, 2024

Should fix:

// If the above feels a little difficult to read, a short-hand could
// be written as follows:

var defineProp = function ( obj, key, value ){
  var config = {
    value: value,
    writable: true,
    enumerable: true,
    configurable: true
  };
  Object.defineProperty( obj, key, config );
};

// To use, we then create a new empty "person" object
var person = Object.create( null );

// Populate the object with properties
defineProp( person, "car",  "Delorean" );
defineProp( person, "dateOfBirth", "1981" );
defineProp( person, "hasBeard", false );

console.log(person);
// Outputs: Object {car: "Delorean", dateOfBirth: "1981", hasBeard: false}

from essential-js-design-patterns.

neojski avatar neojski commented on June 3, 2024

Yup, this looks much better. I just didn't make a PR with this solution as I didn't know if you just forgot config or I missed something.

from essential-js-design-patterns.

neojski avatar neojski commented on June 3, 2024

This is actually duplicate of #81.

from essential-js-design-patterns.

addyosmani avatar addyosmani commented on June 3, 2024

Thanks! It was entirely my fault :) I'll apply a patch for this soon. Thanks for noticing the dupe!

from essential-js-design-patterns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.