原型,原型链,call/apply(5)-实战,call和apply的区别

视频:https://ke.qq.com/course/231577?taid=3983676656552089

实战:

function Person (name,age,sex){
				this.name =name;
				this.age = age;
				this.sex = sex;
			}
			function Student(name,age,sex,tel,grade){
				this.name =name;
				this.age = age;
				this.sex = sex;
				this.tel = tel;
				this.grade = grade;
			}
	var student = new Student("sunny",123,"male",139,2017)

改:

function Person (name,age,sex){
				this.name =name;
				this.age = age;
				this.sex = sex;
			}
			function Student(name,age,sex,tel,grade){
				Person.call(this,name,age,sex)
				this.tel = tel;
				this.grade = grade;
			}
			var student = new Student("sunny",123,"male",139,2017)

 

Call借用别人的

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