x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript</h1>
<h2>prototype 属性</h2>
<p>prototype 属性允许您向字符串添加新的属性和方法。</p>
<p>向所有雇员添加薪酬属性:</p>
<p id="demo"></p>
<script>
function employee(name, jobtitle, born) {
  this.name = name;
  this.jobtitle = jobtitle;
  this.born = born;
}
employee.prototype.salary = 2000;
const fred = new employee("Bill Gates", "CEO", 1955);
document.getElementById("demo").innerHTML = fred.salary;
</script>
</body>
</html>