麻烦老师检查
来源:3-3 编程练习
localhost999
2021-10-20 11:53:17
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</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=function(){ // console.log("run") // } run(){ console.log("run") } static intro="this is a Person class"; static show(){ console.log('show') } } </script> </body> </html>
老师,
run(){
console.log("run")
}
上面这个写法可不可以写成
run=function(){
console.log("run")
}
1回答
同学你好:
1、作业完成的不错,撒欢儿~。
2、如下图,两种写法均可以实现效果,但建议在开发过程中按照ES6的标准去写:
祝学习愉快!
相似问题