Html page:
<button onclick="myFunction()">Try it</button>
<p id="P4"></p>
Javascript page:
<script>
Number.prototype.myMethod = function ()
{
return this.valueOf()
/ 2;
};
function myFunction() {
var n = 55;
document.getElementById("demo").innerHTML
= n.myMethod();
}
</script>
Output:
27.5
No comments:
Post a Comment