js输出变量的类型

<script>
var s="true";
var b=new Boolean(true);
var b1=true;
var r=new RegExp('/d/');
var d=new Date();
document.write(Object.prototype.toString.apply(s));
document.write(Object.prototype.toString.apply(b));
document.write(Object.prototype.toString.apply(b1));
document.write(Object.prototype.toString.apply(r));
document.write(Object.prototype.toString.apply(d));
</script>

输出结果为:

[object String]

[object Boolean]

[object Boolean]

[object RegExp]

[object Date]


by 雪洁 2013-01-18 07:23:27 3879 views
我来说几句

相关文章