On Feb 4, 11:06 am, Angus Croll <[email protected]> wrote:
> Actually you can just say
>
> (0).toFixed(2);
>
> Primitives get temporarily coerced to their object wrappers when faced
> with attribute or function calls. I've never yet had to use new
> Number() but there may yet be a scenario

Awesome, thanks, also to Poetro....George

> On Feb 4, 7:51 am, jemptymethod <[email protected]> wrote:
>
> > I'm setting ExtJS form values in one of their ubiquitous config
> > objects based on JSON data from an Ajax call.
>
> > For currency fields I am calling "toFixed(2)" on the numbers such as:
>
> > jsonObj.shippingAndHandling.toFixed(2)
> > jsonObj.totalDueToday.toFixed(2)
>
> > Etcetera0
>
> > But I have a requirement to default a particular field to 0.00 and
> > when I specify 0.00 as the value in the config object, it shows up as
> > 0 in the UI
>
> > As a work around instead of trying to specify 0.00 I can pass the
> > following and it successfully renders 0.00 in the UI
>
> > (new Number(0)).toFixed(2)

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to