console
function person(name) {
console.log(name);
}
person('js');
function Person(name) {
this.name = name;
this.showMe = function () {
console.log(this.name);
}
}
Person.prototype.from = function () {
console.log('来自prototype');
}
var doudou = new Person('doudou');
doudou.showMe();
console.log(`doudou.prototype: ${doudou.prototype}`);
console.log(typeof Person.prototype);
console.log(Person.prototype.constructor === Person);
doudou.from();
var father = new Person('father');
console.log(`father.constructor,${father.constructor}`);
function SubPerson () {
}
SubPerson.prototype = father;
console.log(SubPerson.prototype.constructor === SubPerson);
SubPerson.prototype.constructor = SubPerson;
var son = new SubPerson();
son.showMe();
son.from();
console.log(father.constructor);
console.log(son.constructor);
console.log(SubPerson.prototype.constructor)
<div>
js
</div>
body{
background: #ccc;
}