parseInt Method
See Also
isNaN Method | parseFloat Method | String Object | valueOf MethodApplies To: Global Object
Requirements
Version 1
Returns an integer converted from a string.parseInt(numString, [radix])
Arguments
numString
Required. A string to convert into a number.
radix
Optional. A value between 2 and 36 indicating the base of the number contained in numString. If not supplied, strings with a prefix of '0x' are considered hexadecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal.
Res
The parseInt method returns an integer value equal to the number contained in numString. If no prefix of numString can be successfully parsed into an integer, NaN (not a number) is returned. parseInt("abc") // Returns NaN.
parseInt("12abc") // Returns 12.
You can test for NaN using the isNaN method.
See Also
isNaN Method | parseFloat Method | String Object | valueOf MethodApplies To: Global Object
Requirements
Version 1
Returns an integer converted from a string.parseInt(numString, [radix])
Arguments
numString
Required. A string to convert into a number.
radix
Optional. A value between 2 and 36 indicating the base of the number contained in numString. If not supplied, strings with a prefix of '0x' are considered hexadecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal.
Res
The parseInt method returns an integer value equal to the number contained in numString. If no prefix of numString can be successfully parsed into an integer, NaN (not a number) is returned. parseInt("abc") // Returns NaN.
parseInt("12abc") // Returns 12.
You can test for NaN using the isNaN method.
解决方案 »
- 40分求Js板块以前一个帖子地址
- 新手想学javascript!求帮助
- 如何把页面元素id通过函数传递?
- Cannot show image and flash
- 如何设置html文件只能使用IE打开,不能使用记事本等其他程序打开?
- 关于Javascript正则的一点小疑问
- Vml+DHtml:VML画板(FYWVml3.0)发布,欢迎在线使用\下载
- 请问JS里DATE对象的时间超时与时间间隔方法有什么区别?谢谢~
- 有没有办法让一个页面跳到所有窗口的最前面?很难!我认为!大家帮忙!来人有分!
- 简单问题,20分!请大家帮忙。。
- 决定免费赠送"易管通" 编辑器代码,不知道这么做对不对咯~~
- 神啊,救救我吧~~一把年纪了,连个select option都搞不定.
See Also
function StatementApplies To: Array Object | Boolean Object | Date Object | Error Object | Function Object | Number Object | Object Object | String Object
Requirements
Version 2
Returns a string representation of an object.objectname.toString([radix])
Arguments
objectname
Required. An object for which a string representation is sought.
radix
Optional. Specifies a radix for converting numeric values to strings. This value is only used for numbers.
Res
The toString method is a member of all built-in JScript objects. How it behaves depends on the object type:Object Behavior
Array Elements of an Array are converted to strings. The resulting strings are concatenated, separated by commas.
Boolean If the Boolean value is true, returns "true". Otherwise, returns "false".
Date Returns the textual representation of the date.
Error Returns a string containing the associated error message.
Function Returns a string of the following form, where functionname is the name of the function whose toString method was called:
function functionname( ) { [native code] }
Number Returns the textual representation of the number.
String Returns the value of the String object.
Default Returns "[object objectname]", where objectname is the name of the object type. Example
The following example illustrates the use of the toString method with a radix argument. The return value of function shown below is a Radix conversion table.function CreateRadixTable (){
var s, s1, s2, s3, x; //Declare variables.
s = "Hex Dec Bin \n"; //Create table heading.
for (x = 0; x < 16; x++) //Establish size of table
{ // in terms of number of
switch(x) // values shown.
{ //Set intercolumn spacing.
case 0 :
s1 = " ";
s2 = " ";
s3 = " ";
break;
case 1 :
s1 = " ";
s2 = " ";
s3 = " ";
break;
case 2 :
s3 = " ";
break;
case 3 :
s3 = " ";
break;
case 4 :
s3 = " ";
break;
case 5 :
s3 = " ";
break;
case 6 :
s3 = " ";
break;
case 7 :
s3 = " ";
break;
case 8 :
s3 = "" ;
break;
case 9 :
s3 = "";
break;
default:
s1 = " ";
s2 = "";
s3 = " ";
} //Convert to hex, decimal & binary.
s += " " + x.toString(16) + s1 + x.toString(10)
s += s2 + s3 + x.toString(2)+ "\n";
}
return(s); //Return entire radix table.
}
<!--
var a ='1.222'
var b = a*1;
alert(typeof(b));
var c = b.toString();
alert(typeof(c))
//-->
</SCRIPT>
{
var b=n;
a1.value='1';
a2.innerHTML='<font color="#0000ff">『全部号码』</font>';
a3.value='<%=b%>';
//a5.innerHTML='<%=2*arrayGroupCounter(2)%>';
a4.innerHTML='<%=b%>';}
</script>这个函数.a* 是组件.N是字符串.如何在n的基础上*2,并显示出来?