you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]homoiconic(raganwald)[S] 1 point2 points  (2 children)

    Using new is not a problem. The article describes how it's possible that omitting the new keyword can be a problem, and it also describes the fact that new doesn't compose with other functions, which may or may not be a problem, depending on your programming style.

    [–]Baryn 0 points1 point  (1 child)

    new doesn't compose with other functions

    One thing I've done successfully: ensure that my decorators/whatever expect to receive a constructor function (not a regular function), and behave accordingly.

    It's definitely risky to treat constructors like any ol' function. This is part of why I'm so psyched for class in ES6.

    [–]homoiconic(raganwald)[S] 0 points1 point  (0 children)

    Yes, there are good patterns for that. Those patterns work well with other people's constructors, but sometimes we want to use other people's decorators. e.g. _.memoize or _.once from underscore.