首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > JavaScript > JavaScript的继承的实现

JavaScript的继承的实现

  • 资源大小:3.65 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: javascript 实现 继承

资 源 简 介

Description A simple JavaScript implementation of object-oriented inheritance. Download http://jsii.googlecode.com/files/jsii-1.0.0.js Usage Example ``` var Shape = Class.extend({ init: function(height, width) { this.height = height; this.width = width; }, info: function() { alert("I have height = " + this.height + " and width = " + this.width); } }); var Rectangle = Shape.extend({ }); var Square = Rectangle.extend({ init: function(size) { this.inherited().init(size, size); } }); var rectangle = new Rectangle(5, 10); var square = new Square(10); rectangle.info(); // it will alert => I have height = 5 and width = 10 square.info(); // it will alert => I have height = 10 and width = 10 ```
VIP VIP
0.162139s