<script type="text/javascript">
function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
this.abc = "abcde";
/*this.hobby=function(){
return 'watching movies';
}*/
}
employee.prototype.hobby=function(){
return 'watching movies';
}
document.write(typeof employee.prototype);
var bill=new employee("Bill Gates","Engineer",1985);
employee.prototype.salary=null;
employee.prototype.age = 123;
bill.salary=20000;
document.write(bill.salary);
document.write(bill.age);
document.write(employee.prototype.age);
document.write(bill.abc);
var bill2=new employee("Bill 2Gates","Engine2er",19825);
document.write(bill2.hobby===bill.hobby);
document.write(bill.hobby);
document.write(bill2.hobby);
console.log(Object.getPrototypeOf(Object.prototype));
console.log(employee.prototype.isPrototypeOf(bill));
console.log(bill instanceof employee);
console.log(null instanceof Object);
console.log(undefined instanceof Object);
function A() {};
A.prototype.hello = function() {
return new this.constructor();
}
function Father() {}
function Son() {
Son.height.constructor.call(this);
}
Son.height = new Father();
</script>
function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
this.abc = "abcde";
/*this.hobby=function(){
return 'watching movies';
}*/
}
employee.prototype.hobby=function(){
return 'watching movies';
}
document.write(typeof employee.prototype);
var bill=new employee("Bill Gates","Engineer",1985);
employee.prototype.salary=null;
employee.prototype.age = 123;
bill.salary=20000;
document.write(bill.salary);
document.write(bill.age);
document.write(employee.prototype.age);
document.write(bill.abc);
var bill2=new employee("Bill 2Gates","Engine2er",19825);
document.write(bill2.hobby===bill.hobby);
document.write(bill.hobby);
document.write(bill2.hobby);
console.log(Object.getPrototypeOf(Object.prototype));
console.log(employee.prototype.isPrototypeOf(bill));
console.log(bill instanceof employee);
console.log(null instanceof Object);
console.log(undefined instanceof Object);
function A() {};
A.prototype.hello = function() {
return new this.constructor();
}
function Father() {}
function Son() {
Son.height.constructor.call(this);
}
Son.height = new Father();
</script>