<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
function Student(name,subject,score){
this.name = name;
this.subjiect = subject;
this.score = score;
}
var stu1 = new Student("司凤","语文",88);
var stu2 = new Student("琉璃","数学",50);
console.log(stu2);
</script>
</body>
</html>
IE控制台显示结果
[object Object] {
[functions]: ,
proto: { },
name: “琉璃”,
score: 50,
subjiect: “数学” }
//修改Student的toString()方法
Student.prototype.toString = function(){
return "Student[name="+this.name+",subject="+this.subject+",score="+this.score+"]";
};
console.log(stu2);
Student[name=琉璃,subject=数学,score=50] {
[functions]: ,
proto: { },
name: “琉璃”,
score: 50,
subject: “数学” }