【发布时间】:2015-12-15 20:25:14
【问题描述】:
此代码不能在最后一行运行。我不知道为什么。
var Vehicle = function() {
var age = 21; //private variable
this.setAge = function(age2) {age = age2;};
this.getAge = function() {return age;};
};
var Plane = function() {};
Plane.prototype = Object.create(Vehicle.prototype);
var plane = new Plane();
console.log( plane instanceof Vehicle );
//console.log( plane.getAge() ); //TypeError: plane.getAge is not a function
【问题讨论】:
标签: javascript