function prototype definition code example
Example 1: 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"
Example 2: prototype
String.prototype.countCharacter = function(char) {
return [...this].filter(c => c === char).length;
}