The example demonstrates how to add the sec() method to the Math object to provide the capability to calculate secants.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> // Add the sec function to the Math object function sec(aValue) { return 1/Math.cos(aValue); } // Register the new function Math.constructor.prototype.sec = sec; // Test the Math.sec() method document.write(Math.sec(2)) document.write("<BR>") </SCRIPT> </BODY> </HTML>
See also: | Math.cosec(), Math.cot() |
Prev | Home | Next |
Math.round() | Up | Math.sin() |
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. |