js prototype function usage 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: function prototype
// function prototype
void add(int, int);
int main() {
// calling the function before declaration.
add(5, 3);
return 0;
}
// function definition
void add(int a, int b) {
cout << (a + b);
}