摘要: 要判断js中某个变量的类型,我首先想到的是用 typeof 这个函数,但是这个函数只有在判断值类型的变量类型时有效,如:表达式返回值typeof(0)numbertypeof("a")stringtypeof(false)booleantypeof(function(){})functionvara;typeof(a)undefined在判断引用类型变量时却不灵光了,因为它们都返回object,如:表达式返回值typeof(null)objecttypeof([])objecttypeof(newDate())objecttypeof(newObject())object这 阅读全文
posted @ 2012-02-02 19:10 小生 阅读(345) 评论(0) 推荐(0)
  2012年2月21日
摘要: 转自:http://blog.csdn.net/kabukon/article/details/6913381Function 1:Object.create这是一个很重要的改动,现在我们终于可以得到一个原型链干净的对象了。以前要创建一个类Js代码functionCat(name){this.name=name;this.paws=4;this.hungry=false;this.eaten=[];}Cat.prototype={constructor:Cat,play:function(){this.hungry=true;return'playing!';},feed:fu 阅读全文
posted @ 2012-02-21 14:29 小生 阅读(759) 评论(1) 推荐(0)