开发者

What's wrong with javascript (toFixed) method?

开发者_Go百科

What's wrong with this code?

var result = 985.toFixed(2);

And the fix is:

var result = (985).toFixed(2);

I still want to know the reason. :)


In the first example, the Javascript interpreter interprets the dot as a decimal point, because it's coming after a number.

Putting brackets around the number gets around this limitation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜