addyosmani / essential-js-design-patterns

Repo for my 'Learning JavaScript Design Patterns' book
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
4.83k stars 792 forks source link

Constructor pattern bug #95

Closed addyosmani closed 10 years ago

addyosmani commented 11 years ago

From the site:

I read your book about design Patterns.

And I think I this fragment:

http://addyosmani.com/resources/essentialjsdesignpatterns/book/#constructorpatternjavascript

Have some little error.

You write the code :

var newObject = {};

var newObject = Object.create( null );

var newObject = new Object();

And the context imply that all these methods provide the same result.

But as the matter of fact the:

  var newObject = Object.create( null ); 

Creates object without Object in prototype chain.

addyosmani commented 11 years ago

Another small one.

The same paragraph.

http://addyosmani.com/resources/essentialjsdesignpatterns/book/#constructorpatternjavascript

Line 39 and down.

You do create

var defineProp = function ( obj, key, value) {
  config.value = value;
  Object.defineProperty( obj, key, config);
};

But you seem to forget define the object config.

pbrewczynski commented 11 years ago

The first issue was already corrected:

In commit : 5487247b

And the second also already corrected

In commit : dd66f3b1

Issue to Close.