📜  函数原型 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:31.830000             🧑  作者: Mango

代码示例3
/*Prototype is used to add properties/methods to a 
constructor function as in example below */

function ConstructorFunction(name){
    this.name = name //referencing to current executing object
}
ConstructorFunction.prototype.age = 18
let objectName = new ConstructorFunction("Bob")
console.log(objectName.age) //18