Answers for "define prototype function"

11

function prototype javascript

function Person(name) {
  this.name = name;
}
Person.prototype.getName = function() {
  return this.name;
}

var person = new Person("John Doe");
person.getName() //"John Doe"
Posted by: Guest on June-02-2020
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
1

prototype meaning

String    Number.0.97.8.582..6985849
90.864.2.3.4.1..5785.9.6..77
Posted by: Guest on July-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language