> The class operator can prefix any UnaryExpression, not just object literals. > That means that the class operator can be used to classify objects: > > if (class p === Point) ... > > Note that many object-oriented abstraction designers consider this for of > class testing to be an anti-pattern. > > It also works with instances of the standard ES built-in constructors: > > if (class new Array(1,2,3,4) === Array) ... //this will be true > > so are these: > > if (class [1,2,3,4] === Array) ... > if (class [].pop === Function) ...
Is it a good idea to overload this operator? 1. class objectExemplar: “turn the `objectExemplar` into a class” 2. class obj: “get the class of obj” I would give operator #2 the name `classof` and let `class` only return the own property value of `constructor`. -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss