I shall end the shitstorm here and now.

To quote the rhino book:

"Once we've created a string object S [through `new String`], what can
we do with it? Nothing that we cannot do with the corresponding
primitive string value. If we use the `typeof` operator, it tells us
that S is indeed an object, and not a string value, but except for
that case, we'll find that we can't normally distinguish between a
primitive string and the String object."

The same applies to Number and Boolean.

In other words, the purpose of the wrapper objects around primitives
is to drive framework authors insane, since they evade introspection:
they walk, talk, eat, and swim like ducks; ask them what they are,
though, and they'll claim to be ostriches.

The reason you've seen such skepticism from kangax in this thread is
because he probably can't think of a single case in which it's
_useful_ to use the wrapper objects instead of the primitives they
wrap. Nor can I. But, hell, if people want it, it's easy enough:

Object.isString = function(object) {
  return object.valueOf && typeof object.valueOf() === "string";

Object.isNumber = function(object) {
  return object.valueOf && typeof object.valueOf() === "number";

The `valueOf` method will return the primitive behind the wrapper
object. And this will avoid the cross-frame issues we had with

We'll put this into the queue for either or 1.6.1, even though
it makes my head hurt.

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to