日期:2014-05-16 浏览次数:20302 次
typeof方法
?
返回一个用来表示表达式的数据类型的字符串:"number" "string" "boolean" "object" "function" 和 "undefined"
<html> <head> <title>number test</title> </head> <body> <input type="button" value="typeof(0)" onclick="javascript:alert(typeof(0));"/><br> <input type="button" value="number.MIN_VALUE" onclick="javascript:alert(Number.MIN_VALUE);"/><br> <input type="button" value="number.MAX_VALUE" onclick="javascript:alert(Number.MAX_VALUE);"/><br> <input type="button" value="number.NEGATIVE_INFINITY" onclick="javascript:alert(Number.NEGATIVE_INFINITY);"/><br> <input type="button" value="number.POSITIVE_INFINITY" onclick="javascript:alert(Number.POSITIVE_INFINITY);"/><br> <input type="button" value="isNaN(0)" onclick="javascript:alert(isNaN(0));"/><br> <input type="button" value="isNaN('a')" onclick="javascript:alert(isNaN('a'));"/><br> <input type="button" value="isFinite(Number.NaN)" onclick="javascript:alert(isFinite(Number.NaN));"/><br> <input type="button" value="isFinite(Number.POSITIVE_INFINITY)" onclick="javascript:alert(isFinite(Number.POSITIVE_INFINITY));"/><br> <input type="button" value="isFinite(Number.NEGATIVE_INFINITY)" onclick="javascript:alert(isFinite(Number.NEGATIVE_INFINITY));"/><br> <input type="button" value="Number.POSITIVE_INFINITY" onclick="javascript:alert(Number.POSITIVE_INFINITY*2 == Number.POSITIVE_INFINITY);"/><br> </body> </html>
<html> <head> <title>function test</title> </head> <body> <script language="javascript"> <!-- function foo1(arg) { foo2(arg, 'b'); } function foo2(arg1, arg2) { foo3(arg1, arg2, 'c'); } function foo3() { var foo = arguments.callee; while (foo) { var args = foo.arguments; for (var i = 0; i < args.length; i++) { document.write(args[i]); } foo = foo.caller; document.write("<br/>"); } } foo1('a'); --> </script> </b