Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #prototype #javascript
ADD COMMENT
Topic
Name
5+8 =