//instanceof、 __proto__、 prototype //简单总结一下这三个东西的使用: //1、只有一个 class 的实例的 __proto__ 等于该 class 的 prototype。而实例 instanceof 可以是所有的父类。 function a(){}; var b=new a(); trace(b.__proto__==a.prototype); //true trace(b.__proto__==Object.prototype); //false trace(b instanceof a); //true trace(b instanceof Object); //true //2、Number 和 String 只有使用 new 操作符以后,才能判断到 instanceof。 var num1=0; var num2=new Number(0); trace(num1 instanceof Number); //false trace(num2 instanceof Number); //true var str1="mmommo"; var str2=new String("mmommo"); trace(str1 instanceof String); //false trace(str2 instanceof String); //true //3、Number 和 String 不论采取哪种方式赋值都一个拿到 __proto__ 属性。 var num1=0; var num2=new Number(0); trace(num1.__proto__==Number.prototype); //true trace(num2.__proto__==Number.prototype); //true var str1="mmommo"; var str2=new String("mmommo"); trace(str1.__proto__==String.prototype); //true trace(str2.__proto__==String.prototype); //true