Comments (6)
In fact, it's not even working as config
was never defined.
from essential-js-design-patterns.
Confirmed. Looking into this now.
from essential-js-design-patterns.
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.
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.
This is actually duplicate of #81.
from essential-js-design-patterns.
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)
- Translate to Chinese HOT 1
- Flyweight Example 1: Centralized event handling code error
- typo in the jquery iterator pattern HOT 2
- Translation to Portuguese Brazil HOT 9
- JS example indentation error. HOT 1
- Book is really hard to read on iPhone 6 HOT 1
- Spanish translation HOT 2
- Bug in Factory Pattern
- Issue in Object Creation Section HOT 1
- Build is broken HOT 1
- update travis.yml to run grunt build task HOT 2
- Dead repository link HOT 1
- Better save to device and device experience HOT 2
- Rewrite build process to use Webpack or Gulp HOT 1
- Great work of this book!
- Second edition: ES2015 HOT 18
- Translate to Chinese HOT 1
- Decorator Pattern extend() HOT 1
- Question about the vehicle factory example HOT 2
- Color Theme from online book
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from essential-js-design-patterns.