The specific code is as follows:
//Define function
function people(name,sex,age){
this.name = name;
this.sex = sex;
this.age = age;
}
//Share isStudent and sayName methods
people.prototype = {
isStudent:true,
sayName:function(){
alert(this.name);
}
}
var people1 = new people('Han Meimei','女',16); //Instantiate object 1
var people2 = new people('Li Lei','Male',17); //Instantiate object 2
//Let two objects say their names through the sharing method
people1.sayName();
people2.sayName();
//Judging from the shared parameters that they are all students
if(people1.isStudent == people2.isStudent)alert('They are all students');
This article also mentions some knowledge about JavaScript objects, which should not be difficult to understand. If you really don’t understand, you can search on Baidu.