Math.sec() (Simulated functionality)

The sec() function is not available in JavaScript but can be simulated to aid in the porting of existing code.

The example demonstrates how to add the sec() method to the Math object to provide the capability to calculate secants.

Example code:

   <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()