The example demonstrates how to add the cot() method to the Math object to provide the capability to calculate cotangents.
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT>
// Add the cot function to the Math object
function cot(aValue)
{
return 1/Math.tan(aValue);
}
// Register the new function
Math.constructor.prototype.cot = cot;
// Test the Math.cot() method
document.write(Math.cot(2))
document.write("<BR>")
</SCRIPT>
</BODY>
</HTML>| See also: | Math.cosec(), Math.sec() |
| Prev | Home | Next |
| Math.cosh() | Up | Math.E |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. | ||