Files
Avideo/index.html
2024-09-27 01:25:59 +08:00

35 lines
785 B
HTML

<!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>
</body>
<script>
class Test {
constructor(name) {
this.name = name;
}
getName() {
return this.name;
}
}
var test = new Test("张三");
console.log("test: ",test);
console.log(test.getName());
// 类的 prototype 等于 对象的 __proto__
// 显式原型 = 隐式原型
// console.log(Test.prototype === test.__proto__);
// constructor 外的方法会成为实例化对象的共有方法
// 类的公有方法不会开辟新的内存,以此达到节省内存的目的
</script>
</html>