阅读背景:

原型对象基本的写法和方法相互调用

来源:互联网 

1.基本写法

function Student(name,age,sex){
	
	this.name=name;
	this.age=age;
	this.sex=sex;
	
}
//简单的写法
Student.prototype={
	constructor:Student,
	height:"188px",
	width:"55kg",
	study:function(){
		console.log("学习好凯西");
	},
	eat:function(){
		console.log("我要吃好吃的");
	},
}
var stu=new Student("段飞",20,"女");
	
	stu.eat();
	stu.study();
	console.log(Student);
	console.log(stu);	
function Student(name,age,sex){
	



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: