javascript oop编程 — 实现继承的三种形式[1](1)模拟类的方式, 我们都知道js是原型继承机制,不存在class和instance分离的这种方式假设,我们有两个类function Animal(){ this.name = “animal”; this.eat = function(){ consle.log(“eating");  
javascript 的函数在执行期间才会确定他的context,也就是说this在此时被赋值。但是你常常遇到这种情况function process(){ this.name = "hello"; document.onclick = function(){ alert(this.name);
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号