---
title: "prototype"
author: "dmwdmc"
date: "2013-06-13T17:48:22Z"
tags: []
categories: ["Web前端"]
slug: "prototype"
draft: false
lastmod: "2013-06-18T21:26:27Z"
id: 1886287
url: "https://dmwdmc.iteye.com/blog/1886287"
---

below  2 ways can define a class.
					{member:value}  
					function(){this.member=value}
				  functionSon.prototype=functionFather.prototype;

					e.g
	
> 						<script>
> 									var bbs={
> 									name : "java",
> 									version: "2.0",
> 									sayHello:function(){alert(this.version);}
> 									}
> 								       var fna=function(){
> 									this.name="aaa";
> 									this.rate=11;
> 									this.ccc=bbs;
> 									};
> 		
> 
> 							var fnb=new fna();
> 									alert(fnb.ccc.name);
> 									var fnc=function(){};
> 									fnc.prototype={
> 									name:"ccc",
> 									rate:222
> 									}
> 	
> 以下可以实现继承								var fnd=function(){
> this.k='11k';
> }; 
> fnd.prototype=fnc.prototype; 
> 
> var dc=new fnd(); 
> alert(dc.name); 
> alert(dc.k);									</script>



我们页面跳出ccc(dc.name),和 11k(dc.k ),
说明fnd集成的fnc的name,并且有了自己的扩展k