码迷,mamicode.com
首页 > Web开发 > 详细

js 原型prototype

时间:2017-05-09 20:40:27      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:cti   func   使用   arch   htm   mdi   blog   function   div   

function MyObject(name, size)
{
  this.name = name;
  this.size = size;
}

MyObject.prototype.height = "2.26 meters";
MyObject.prototype.tellHeight = function()
{
  return "height of "+this.name+" is "+this.height;
}

///////使用
var myobj1 = new MyObject("haha", 3);
if (myobj1.tellHeight)
{
  domDiv.innerHTML += myobj1.tellHeight()+";
}

http://www.cnblogs.com/lidabo/archive/2012/01/05/2313481.html

 

js 原型prototype

标签:cti   func   使用   arch   htm   mdi   blog   function   div   

原文地址:http://www.cnblogs.com/wulinwulin/p/6832341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!