for arithmetic purposes, the "nan" value is not a number in any radix. you can call the isnan function to determine if the result of parsefloat is "nan". if "nan" is passed on to arithmetic operations, the operation results will also be "nan".
例子
the following 例子 all return 3.14:
parsefloat("3.14")
parsefloat("314e-2")
parsefloat("0.0314e+2")
var x = "3.14"
parsefloat(x)
the following example returns "nan" or 0:
parsefloat("ff2")
相关
parseint function
parses a string argument and returns an integer of the specified radix or base.
语法
parseint(string [,radix])
string is a string that represents the value you want to parse.
radix is an integer that represents the radix of the return value.
description
the parseint function is a built-in javascript function. it is not a method associated with any object, but is part of the language itself.
the parseint function parses its first argument, a string, and attempts to return an integer of the specified radix (base). for example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. for radixes above 10, the letters of the alphabet indicate numerals greater than 9. for example, for hexadecimal numbers (base 16), a through f are used.
if parseint encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. parseint truncates numbers to integer values.
if the radix is not specified or is specified as 0, javascript assumes the following:
if the first character cannot be converted to a number, parsefloat returns one of the following values:
for arithmetic purposes, the "nan" value is not a number in any radix. you can call the isnan function to determine if the result of parseint is "nan". if "nan" is passed on to arithmetic operations, the operation results will also be "nan".
例子
the following 例子 all return 15:
parseint("f", 16)
parseint("17", 8)
parseint("15", 10)
parseint(15.99, 10)
parseint("fxx123", 16)
parseint("1111", 2)
parseint("15*3", 10)
the following 例子 all return "nan" or 0:
parseint("hello", 8)
parseint("0x7", 10)
parseint("fff", 10)
even though the radix is specified differently, the following 例子 all return 17 because the input string begins with "0x".
parseint("0x11", 16)
parseint("0x11", 0)
parseint("0x11")
相关
password object
a text field on an htm form that conceals its value by displaying asterisks (*). when the user enters text into the field, asterisks (*) hide anything entered from view.
语法
to define a password object, use standard htm 语法:
<input type="password" name="passwordname" [value="textvalue"] size=integer>name="passwordname" specifies the name of the password object. you can access this value using the name property.
value="textvalue" specifies the initial value of the password object. you can access this value using the defaultvalue property.