# OOP ?
## 封装: 低耦合 and 高内聚
## 多态:重载 and 重写
function sum(x,y,z) {
if(typeof z === 'undefined') {
return ;
}
}
sum(1,2);
sum(1,2,3);
# 继承
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function A(x) {
this.x=x ;
}
A.prototype.getX=function() {
console.log(this.x);
}
function B(y){
this.y=y ;
}
B.prototype.getY = function() {
console.log(this.y);
}
let b1 = new B(100);
b1.y;
</script>
</body>
</html>