<!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 Lin { constructor(name, age) { this.money = 10000000000000000; this.name = name; this.age = age; } mishu() { console.log('lin的秘书'); } } class Cong extends Lin { constructor(name, age) { super(name, age) this.girl = '女朋友'; this.money = 888; } mishu() { console.log('cong的秘书'); } } var xiaowang = new Cong('聪聪', 38); console.log(xiaowang); // 属性的访问规则:自己有就用自己的,自己没有才用父亲的 // 方法的访问规则:自己有就用自己的,自己没有才用父亲的 console.log(xiaowang.money); xiaowang.mishu(); </script> </body> </html>
// 属性的访问规则:自己有就用自己的,自己没有才用父亲的
// 方法的访问规则:自己有就用自己的,自己没有才用父亲的
还没有评论,来说两句吧...