企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ function Fn() { var n = 10; this.m = 20; this.aa = function () {console.log(this.m);} } Fn.prototype.bb = function () {console.log(this.n);}; var f1=new Fn; Fn.prototype={ aa:function(){console.log(this.m+10);} }; var f2=new Fn; console.log(f1.constructor); //Fn console.log(f2.constructor); //Object f1.bb(); //undefined f1.aa(); //20 // f2.bb(); //報錯 f2.aa(); // 20 f2.__proto__.aa(); // NaN ~~~ ![](https://img.kancloud.cn/87/34/873495b7f5f4ba7f34419db8d79a5530_767x556.png) ![](https://img.kancloud.cn/14/e2/14e24d6dab5ee09e3f46d3cf31559f13_1212x406.png)