数字串? [英] Number to string??

查看:70
本文介绍了数字串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么将其转换为字符串???

var newidNumber =((idNumber / 2).toFixed())+ 1;


谢谢

Mike

Why is this converted to a string???
var newidNumber =((idNumber/2).toFixed())+1;

Thanks
Mike

推荐答案

11月28日下午4:35,Mike< ampel ... @ gmail。编写:
On Nov 28, 4:35 pm, Mike <ampel...@gmail.comwrote:

为什么将其转换为字符串???

var newidNumber =((idNumber / 2).toFixed()) +1;
Why is this converted to a string???
var newidNumber =((idNumber/2).toFixed())+1;



因为 - toFixed - 方法返回一个字符串。

Because the - toFixed - method returns a string.


11月28日上午10点37分, Henry< rcornf ... @ raindrop.co.ukwrote:
On Nov 28, 10:37 am, Henry <rcornf...@raindrop.co.ukwrote:

11月28日下午4:35,Mike< ampel ... @ gmail.comwrote :
On Nov 28, 4:35 pm, Mike <ampel...@gmail.comwrote:

为什么将其转换为字符串???

var newidNumber =((idNumber / 2).toFixed())+ 1;
Why is this converted to a string???
var newidNumber =((idNumber/2).toFixed())+1;



因为 - toFixed - 方法返回一个字符串。


Because the - toFixed - method returns a string.



当你想将变量用作数字时使用eval()返回

数字

when you want to use the variable as a number use eval() to return a
number


11月28日下午4:45,kendalk08< kendal ... @ gmail.comwrote:
On Nov 28, 4:45 pm, kendalk08 <kendal...@gmail.comwrote:

11月28日,10:凌晨37点,Henry< rcornf ... @ raindrop.co.ukwrote:
On Nov 28, 10:37 am, Henry <rcornf...@raindrop.co.ukwrote:

11月28日下午4:35,Mike< ampel ... @ gmail.comwrote:
On Nov 28, 4:35 pm, Mike <ampel...@gmail.comwrote:


为什么这会转换为字符串???

var newidNumber =((idNumber / 2).toFixed())+ 1;
Why is this converted to a string???
var newidNumber =((idNumber/2).toFixed())+1;


因为 - toFixed - 方法返回一个字符串。
Because the - toFixed - method returns a string.



当你想使用变量作为数字时使用eval()来表示

返回一个数字


when you want to use the variable as a number use eval() to
return a number



不,谢谢,我会使用一元加运算符,数字构造函数

作为函数,parseInt或parseFloat调用,具体取决于

情况。 - eval - 函数将是使用
的绝对最差的方法,特别是当它的行为是不可预测的时,只要它的

参数是一个不代表数字的字符串。 br />

No thanks, I will use the unary plus operator, the Number constructor
called as a function, parseInt or parseFloat, depending on the
situation. The - eval - function would be the absolute worst method to
use, particularly as its behaviour is unpredictable whenever its
argument is a string that does not represent a number.


这篇关于数字串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆