1.基本函数原型链:
代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
function Base() {
}
</script>
</head>
<body>
</body>
</html>
产生的原型链如下图所示:
2. class定义原型链
代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
class Base{
constructor(){}
}
class Person extends Base{
constructor(){
super();
}
}
</script>
</head>
<body>
</body>
</html>
产生的原型链如下图所示: