On Mar 4, 4:00 pm, Marcello Bastéa-Forte <[email protected]>
wrote:
> String is an object, right?  But a non-null String (i.e. length==0) can
> evaluate as false... so it sounds like a contradiction.

Actually, strings are primitive values and also can have a object
form:

js> function f(a) { print(typeof a); print(a ? true : false); }
js> f("");
string
false
js> f(new String(""));
object
true

>
> Is there no way to make a custom class act like a String in the case of
> length==0?
>
> Feel free to tell me you think this is a bad idea and breaks convention too
> much.
>
> Marcelo
>
> > ECMA is pretty clear that ToBoolean on an object is true. Why would
> > you want to change this?
>
> > --N
> > _______________________________________________
> > dev-tech-js-engine-rhino mailing list
> > [email protected]
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhi
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to