首页 > 代码库 > javascript篇:javascript对象

javascript篇:javascript对象

此系列文章记录javascript的内置对象,包含内容如下(参照W3School的介绍来做的笔记):

  • Array
  • Boolean
  • Date
  • Math
  • Number
  • String
  • RegExp
  • Functions
  • Events
  • Window系列,DOM系列

  javascript对象大多包含一个constructor属性,返回对应的函数对象的引用,这有时候会有点小用处呢:

 1 <script type="text/javascript"> 2  3 var test=new Array(); 4  5 if (test.constructor==Array) 6 { 7 document.write("This is an Array"); 8 } 9 if (test.constructor==Boolean)10 {11 document.write("This is a Boolean");12 }13 if (test.constructor==Date)14 {15 document.write("This is a Date");16 }17 if (test.constructor==String)18 {19 document.write("This is a String");20 }21 22 </script>
 1 <script type="text/javascript"> 2  3 function employee(name,job,born) 4 { 5 this.name=name; 6 this.job=job; 7 this.born=born; 8 } 9 10 var bill=new employee("Bill Gates","Engineer",1985);11 12 document.write(bill.constructor);13 14 </script>