老师这样写是正确的吗?
来源:3-3 编程练习
3颗猫饼干
2021-12-16 15:12:03
相关代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3-3</title>
</head>
<body>
<script>
/*
function Person(name, age) {
this.name = name;
this.age = age;
this.say = function() {
console.log(this.name, this.age)
}
}
Person.prototype.run = function() {
console.log("run")
}
Person.intro = "this is a Person class"
Person.show = function() {
console.log('show')
}
*/
class Person {
constructor(name,age) {
this.name = name;
this.age = age;
this.say = function(){
console.log(this.name,this.age);
}
}
run(){
console.log('run');
}
static intro = "this is a Person class"
static show(){
console.log('show');
}
}
</script>
</body>
</html>1回答
好帮手慕慕子
2021-12-16
同学你好,代码实现是正确的,很棒!!!祝学习愉快~
相似问题