JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
JavaScript
function Person() {
this.name='zxf'
}
function Son() {
Person.call(this,arguments)
this.age=45
}
Person.prototype.getName=function(){
return this.name
}
// Son.prototype = Object.create(Person && Person.prototype, {
// constructor: {
// value: Son,
// enumerable: false,
// writable: true,
// configurable: true
// }
// });
Object.setPrototypeOf(Son.prototype,Person.prototype)
const son=new Son()
Son.prototype.getAge=function(){
return this.age
}
document.write(son.getName())