<!DOCTYPE HTML>
<
html
>
<
head
>
<
title
>
JavaScript String prototype Property
</
title
>
</
head
>
<
body
style
=
"text-align:center;"
>
<
h1
>GeeksForGeeks</
h1
>
<
p
id
=
"GFG_UP"
></
p
>
<
button
onclick
=
"GFG_Fun();"
>
Click Here
</
button
>
<
p
id
=
"GFG_DOWN"
></
p
>
<
script
>
var up = document.getElementById('GFG_UP');
var down = document.getElementById('GFG_DOWN');
function person(name, age) {
this.name = name;
this.age = age;
}
var p1 = new person("p1", 22);
up.innerHTML = "Click on the button to add"
+ " a new property to all objects "
+ "of a given type.<
br
> "
+ JSON.stringify(p1);
function getData(name, age) {
return "Information of person <
br
>Name - '"
+ name + "'<
br
>Age - " + age;
}
function GFG_Fun() {
person.prototype.info
= getData(p1.name, p1.age);
down.innerHTML = p1.info;
}
</
script
>
</
body
>
</
html
>