<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
</style>
</head>
<body>
<div id="wrap"></div>
<script>
class Teacher{
// 私有属性的内容
constructor(n,a) {
this.name = n;
this.age = a;
}
// 公有属性
// prototype ES6中只允许原型里边有方法,不允许其他数据类型
company(){
return "阿里巴巴"
}
sayName(){
console.log(this.name);
}
sayAge(){
console.log(this.age);
}
}
let knight = new Teacher("knight",19);
console.log(knight);
knight.sayName();
knight.sayAge();
console.log(knight.company());
</script>
</body>
</html>
Python3Turtle