JS继承

	function Base(name){
		this.name = name;
		this.getName = function(){
			return this.name;
		}
	}
	
	function Child(id){
		this.id = id;
		this.getId = function(){
			return this.id;
		}
	}
	
	Child.prototype = new Base('base');
	var ch = new Chilc('child');
	
	alert(ch.getId());
	alert(ch.getName());

你可能感兴趣的:(JavaScript,prototype)