diff --git a/_posts/2014-07-09-javascript-constructor-problem.md b/_posts/2014-07-09-javascript-constructor-problem.md index bda51c7c6..9da93a4cf 100644 --- a/_posts/2014-07-09-javascript-constructor-problem.md +++ b/_posts/2014-07-09-javascript-constructor-problem.md @@ -177,7 +177,7 @@ snafu.concatenated() //=> 'Situation Normal All Fsked Up' {% endhighlight %} -Now it works, but of course `snafu` is an instance of `Fubar`, not of `LoggingFubar`. Is that what you want? Who knows!? This isn't a justification for the pattern, as much as an explanation that it is a useful, but leaky abstraction. It's doesn't "just work," but it can make certain things possible (like decorating constructors) that are otherwise even more awkward to implement. +Now it works, but of course `snafu` is an instance of `Fubar`, not of `LoggingFubar`. Is that what you want? Who knows!? This isn't a justification for the pattern, as much as an explanation that it is a useful, but leaky abstraction. It doesn't "just work," but it can make certain things possible (like decorating constructors) that are otherwise even more awkward to implement. ### solution: overload its meaning @@ -253,4 +253,4 @@ var arrayOfSevereProblems = problems.filter(Fubar.is); There you have it: Constructors that fail when called without `new` are a potential problem, and three solutions we can use are, respectively, auto-instantiation, overloading the constructor, or killing such calls with fire. -(discuss on [reddit](http://www.reddit.com/r/javascript/comments/2acr9f/a_javascript_constructor_problem_and_three/)) \ No newline at end of file +(discuss on [reddit](http://www.reddit.com/r/javascript/comments/2acr9f/a_javascript_constructor_problem_and_three/))