Sunday, April 22, 2007

Javascript クラス コンストラクトの例

<script type=text/javascript>
<!--

function Team(name,members){
this.name = name;
this.members = members;
}

Team.prototype.add = function(members){
this.members += members;

};

football = new Team("Japan",11);
football.add(3);
document.write("Team name:"+ football.name + ", members:"+football.members);

//-->
</script>

No comments: