<!doctype html>
<html>
<head>
<title>javascript new</title>
<script>
function employee() {
this.name = "myname";
this.dept = "dept03";
}
employee.prototype = {
say : "hello"
}
//创建对象
var p1 = new employee();
//等价于如下步骤
var p2 = {};
employee.apply(p2);
p2.__proto__ = employee.prototype;
console.log(p1, p2);
</script>
</head>
<body>
</body>
</html>