Marius Gundersen (2013-09-08T10:47:51.000Z)
So how about implementing toBoolean as an overridable method, which is
called whenever !, || or && are used. This way an objec has three method
for converting it into a primitive; toString, toValue and toBoolean.

Marius Gundersen


On Sun, Sep 8, 2013 at 2:19 AM, Till Schneidereit <till at tillschneidereit.net
> wrote:

> On Sun, Sep 8, 2013 at 2:15 AM, Marius Gundersen <gundersen at gmail.com>wrote:
>
>> > That's the way ToBoolean has always been defined
>> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.1.2 . All
>> objects are considered to be Boolean true values.
>>
>> So does this mean I can override toBoolean to change the way ! behaves on
>> an object?
>>
> No, ToBoolean is a spec-internal abstract operation. I.e., it's a
> collection of steps to be taken whenever the operation is required by the
> specification of some other operation, but it's not available to JS code.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130908/e79a2709/attachment.html>
domenic at domenicdenicola.com (2013-09-18T19:02:13.283Z)
So how about implementing `toBoolean` as an overridable method, which is
called whenever `!`, `||` or `&&` are used. This way an object has three method
for converting it into a primitive; `toString`, `toValue` and `toBoolean`.