posts - 38, comments - 65, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

javascript 继承

Posted on 2011-01-28 22:44 脚印 阅读(124) 评论(0) 编辑 收藏

javascript中继承不像c#中 class B:A

 javascript 中继承通过设置

function super{

  Id:"myid",

  myMethod:funciton(){

   alert("call myMethod!"); 

  } 

 

function sub{

   

//sub继承super

sub.prototype =new super();

 

var A= new sub();

 此时 A就包含属性ID 和方法 myMethod()