Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
Which would naturally mislead the readers to think they are equivalent. You should note that Object.create(null) do not inherit the Object.prototype.
There is also an error in the code example:
constdefineProp=function(obj,key,value){config.value=value;// config is not defined???Object.defineProperty(obj,key,config);}defineProp(newObject,'someKey','Hello World');
Hi, thanks for the feedback! I've corrected said code snippet. Thanks for pointing that out.
As for your first concern. They indeed have some differences but I figured to just write something about it as a different topic. I should've gone first with that but my intention was first and foremost, to learn design patterns for myself. Right now, I'm just addressing JavaScript caveats that has something to do with design patterns context within JavaScript. Like defining a function within the function constructor versus via the prototype.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Had a quick look at the "Creational Design Patterns".
You put these three together:
Which would naturally mislead the readers to think they are equivalent. You should note that
Object.create(null)
do not inherit theObject.prototype
.There is also an error in the code example:
Hi, thanks for the feedback! I've corrected said code snippet. Thanks for pointing that out.
As for your first concern. They indeed have some differences but I figured to just write something about it as a different topic. I should've gone first with that but my intention was first and foremost, to learn design patterns for myself. Right now, I'm just addressing JavaScript caveats that has something to do with design patterns context within JavaScript. Like defining a function within the function constructor versus via the prototype.