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

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

JavaScript的继承的实现

  • 资源大小:3.65 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:1次
  • 资源积分: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