:))) thank you. On Tue, Jun 8, 2010 at 3:23 PM, Vyacheslav Egorov <[email protected]>wrote:
> Hi Vlad, > > It is consistent with what ECMA 262 defines as consistent ;-) > > If you compare sections 9.2 ToBoolean and 9.3 ToNumber you will notice that > ToBoolean(v) just returns true if v is Object, but ToNumber(v) returns > ToNumber(ToPrimitive(v, hint Number)) if v is Object. So ToNumber(new > Number(777)) actually ends up calling Number.prototype.valueOf which in turn > gets 777 from inside number object and returns it. > > -- > Vyacheslav Egorov > > > On Wed, Jun 9, 2010 at 12:09 AM, vlad vladbph <[email protected]> wrote: > >> ...one thing though. it is not consistent with Number() then. Same >> example: >> v = new Number(777); >> >> would give right value when >> v8::Handle<v8::Value> v = g->Get(v8::String::New("v")); >> >> v->ToNumber()->Value() // == 777 >> >> ... >> >> On Tue, Jun 8, 2010 at 3:06 PM, vlad vladbph <[email protected]> wrote: >> >>> Thank you, that helps! >>> >>> >>> On Tue, Jun 8, 2010 at 3:03 PM, Aaron Boodman <[email protected]> wrote: >>> >>>> In JavaScript, you would use the valueOf() method: new >>>> Boolean(false).valueOf() => false. You can do that from v8 too, by >>>> casting your value to an Object, then finding its "valueOf" method, >>>> then calling it. It's a little bit laborious but I can't see any other >>>> way. >>>> >>>> On Tue, Jun 8, 2010 at 2:54 PM, vlad <[email protected]> wrote: >>>> > Thank you Aaron, but how to get to the actual value in v8? >>>> > >>>> > On Jun 8, 2:46 pm, Aaron Boodman <[email protected]> wrote: >>>> >> On Tue, Jun 8, 2010 at 11:13 AM, Aaron Boodman <[email protected]> >>>> wrote: >>>> >> > On Tue, Jun 8, 2010 at 11:09 AM, vlad <[email protected]> wrote: >>>> >> >> "any = new Boolean(false);" >>>> >> >>>> >> > Not a bug. This is a classic javascript thing. Try this in >>>> JavaScript >>>> >> > (no v8 required): >>>> >> >>>> >> > var foo = new Boolean(false); >>>> >> > alert(foo == true); // says "false" >>>> >> >>>> >> > The problem is that: >>>> >> >>>> >> > alert(typeof foo); // says "object", not "boolean" >>>> >> >>>> >> > - a >>>> > >>>> > -- >>>> > v8-users mailing list >>>> > [email protected] >>>> > http://groups.google.com/group/v8-users >>>> > >>>> >>>> -- >>>> v8-users mailing list >>>> [email protected] >>>> http://groups.google.com/group/v8-users >>>> >>> >>> >> -- >> v8-users mailing list >> [email protected] >> http://groups.google.com/group/v8-users >> > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
