Math.cot() (Simulated functionality)

The cot() 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 cot() method to the Math object to provide the capability to calculate cotangents.

Example code:

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