Answers for "prototype in javacript"

2

prototype javascript

/*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
Posted by: Guest on August-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language