Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Prototype Example

 class Person
 {
  constructor(name)
  {
this.name = name;
  }
 }
Person.prototype.x = function(){return this.name};
p = new Person("dfrewiop");
console.log(p.x());
}
/*Prototype.prototype.x = this.name will not work*/
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Prototype #Example
ADD COMMENT
Topic
Name
7+6 =