123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!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>Document</title>
- </head>
- <body>
- <script>
- class Person{
- constructor(name){
- this.name = name
- }
- //方法
- eat(){
- console.log(this,'吃')
- }
- //类 方法 调用
- static say(){
- console.log(this,'xxxxxxxx')
- }
- }
- class Coder extends Person{
- constructor(name,age){
- super(name)
- this.age = age
- }
- }
- var p1 = new Person('zs')
- console.log(p1)
- Person.say()
- var a1 = new Coder('lisi',18)
- console.log(a1)
- a1.eat()
- </script>
- </body>
- </html>
|