《悟透javascript》-3.1
来源:互联网 发布:程序员的数学pdf 编辑:程序博客网 时间:2024/05/28 17:07
闭包;
当碰到对象之间复杂的循环引用时,垃圾回收的判断逻辑非常复杂。故有时才用原型模型;
// 定义构造函数function Person(name){ this.name=name;}// 方法定义到构造函数的原型上Person.prototype.SayHello=function(){ console.log("hello,I'm "+this.name)};// 子类构造函数function Employee(name,salary){ Person.call(this,name);//调用上层构造函数 this.salary=salary;}Employee.prototype=new Person();Employee.prototype.ShowMeTheMoney=function(){ console.log(this.name+" $ "+this.salary)}var BillGates=new Person("Bill Gates");BillGates.SayHello();var SteveJobs=new Employee("Steve Jobs",1234);SteveJobs.SayHello();SteveJobs.ShowMeTheMoney();
阅读全文
0 0
- 《悟透javascript》-3.1
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 悟透JavaScript
- 设置系统的当前时间
- SharedPreferencesUtil
- UVa1343
- ubuntu+idea+spark+scala,编译项目报错java.net.BindException: Cannot assign requested address
- 使用RTL-SDR和Matlab Simulink玩转软件无线电(十四)
- 《悟透javascript》-3.1
- Spring框架01
- 【算法】 状态压缩 位运算在01集合中点点运用
- linux下的高效代码搜索工具-ack
- PHP QR Code生成二维码
- Python+Selenium--XPath的使用
- 判断字符串是否包含中文
- C++ Primer 第五版习题10.32
- Hexo+Next在Github上搭建博客教程