摘要: MyClass = function () { this.A = 1;}MyClass.prototype.X = function () { this.B = 2;}MyClass.prototype.Y = function () { this.Z = function () { this.C = 3; }}/* 内部对象的 this ? */obj = new MyClass();alert(obj.A); //1obj1 = new obj.X();alert(obj1.B); //2obj2 = new (new obj... 阅读全文
posted @ 2012-03-19 16:17 万一 阅读(1985) 评论(2) 推荐(0) 编辑
摘要: MyClass = function () { var A = 1; //内部成员 B = 2; //内部成员 this.C = 3; //对象成员}MyClass.prototype.D = 4; //对象成员(通过原型扩展)obj = new MyClass();alert(obj.A); //undefinedalert(obj.B); //undefinedalert(obj.C); //3alert(obj.D); //4alert(obj.hasOwnProperty('C')); //trueal... 阅读全文
posted @ 2012-03-19 13:48 万一 阅读(1549) 评论(3) 推荐(0) 编辑
摘要: /* 类属性、对象属性 */Array.Info1 = "Info1"; //为 Array 增加类属性 Info1Array.prototype.Info2 = "Info2"; //为 Array 增加对象属性 Info2arr = [1, 2, 3];alert(arr.Info1); //undefinedalert(arr.Info2); //Info2alert(Array.Info1); //Info1/* 类方法、对象方法 */Array.ShowMessage = function () { alert("ClassMessa 阅读全文
posted @ 2012-03-19 12:10 万一 阅读(1618) 评论(0) 推荐(0) 编辑
摘要: /* 值类型 */n1 = 123;n2 = n1; //赋值n2 = 456;alert(n1); //123; n1 != n2/* 对象类型 */arr1 = [123];arr2 = arr1; //引用arr2[0] = 456;alert(arr1[0]); //456; arr1 === arr2 阅读全文
posted @ 2012-03-19 10:02 万一 阅读(1590) 评论(2) 推荐(0) 编辑