2007-08-06
关于typeof运算符
关键字: javascripttypeof 运算符返回一个用来表示表达式的数据类型的字符串。
可能的字符串有:"number"、"string"、"boolean"、"object"、"function" 和 "undefined"。
一个很简单的例子
<html>
<head>
<script language="JavaScript">
var a=function(){
alert("This is in the function of a");
}
document.writeln("返回string,typeof('aa')=="+typeof('aa'));
document.writeln("<br/>返回number,typeof(8)=="+typeof(8));
document.writeln("<br/>返回boolean,typeof(true)=="+typeof(true));
document.writeln("<br/>返回object,typeof(document.getElementById('div'))=="+typeof(document.getElementById('div')));
document.writeln("<br/>返回undefined,typeof(cc)=="+typeof(cc));
document.writeln("<br/>返回function,typeof(a)=="+typeof(a));
</script>
</head>
<body>
<div id="div"></div>
</body>
</html>
发表评论
- 浏览: 17549 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
2008-6-26
共 122 张
共 122 张
最近加入圈子
最新评论
-
创建XMLHttpRequest对象及 ...
返回XML文档 PrintWriter out = null; try ...
-- by weiweichen1985 -
存储过程的创建和调用。。 ...
嵌套循环 CREATE DEFINER=`root`@`localhost` ...
-- by weiweichen1985 -
js实现的年月日三级联动
日历来的更简洁,让用户操作三遍,不符合用户体验。
-- by igogo007 -
js实现的年月日三级联动
谢谢了,代码我收藏了啊
-- by hanhan7673 -
word提示用安全模式打开
...
-- by sunfengcheng






评论排行榜