Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Why is Angular2 encourage/forcing this anti-pattern on developers? What value is there in using instanceof to test an Event type? Commented Oct 21, 2016 at 16:42
  • I don't use TS myself (only Dart) and in Dart and other languages I know this is no antipattern. Perhaps filter like shown in stackoverflow.com/questions/33520043/… is a bit of an improvment. Commented Oct 21, 2016 at 17:53
  • 1
    In JavaScript it is a very confusing pattern because it looks like it does in other languages, but it doesn't even have the same kinds of operands. Java : x instanceof T -> x is a value and T is a type; JavaScript : x instanceof T -> x is a value and T is a value; It also couples you to an implementation detail, why should I care that it has a specific prototype? Commented Oct 21, 2016 at 18:39