pow() JavaScript math function

pow is a math function in JavaScript to get to the power value of an integer. Here is the syntax
Math.pow(x,y)
We will try some examples.
<script language='JavaScript' type='text/JavaScript'>
<!--
document.write(Math.pow(5,5)); // output is 3125
document.write("<br>");
document.write(Math.pow(0,0)); // output is 1
document.write("<br>");
document.write(Math.pow(0,1)); // output is 0
document.write("<br>");
document.write(Math.pow(1,0)); // output is 1
document.write("<br>");
document.write(Math.pow(1,1)); // output is 1
document.write("<br>------------<br>");
document.write(Math.pow(2,2)); // output is 4
document.write("<br>");
document.write(Math.pow(2,-2)); // output is 0.25
document.write("<br>");
document.write(Math.pow(-2,2)); // output is 4
document.write("<br>");
document.write("<br>------------<br>");
//-->
</script>
By using for loop we can develop one table , here is sample code
for(i=0;i<5;i++){
for(j=0;j<5;j++){
document.write(Math.pow(j,i)+",");
}
document.write("<br>");
}

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2016 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer