On Nov 14, 2011, at 2:24 PM, Allen Wirfs-Brock wrote: > On Nov 14, 2011, at 1:15 PM, Axel Rauschmayer wrote: > >>> 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”
These are one and the same operator, as Allen says. >> I would give operator #2 the name `classof` and let `class` only return the >> own property value of `constructor`. > > > I'm not over-loading the class operator. I the above I was simply pointing > out that this is what the operator I defined does in those circumstances. The > concept of a constructor function being the "class" of an object is one of > those things that has been around JS apparently from the beginning. It just > didn't have a suggestively named operator. However an object is > instantiated, this operator is simply reporting that the "class"of the object > whatever is accessible as the object's "constructor". I'm really warming up to this radical class-as-unary-get-the-constructor operator. But, I think the missing 'constructor' method bug will bite people. Should class throw if there is no own 'constructor' property? Mutating is out, and copying is out too. /be _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

