Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:Math:sin

From MDC


Contents

[edit] Summary

Returns the sine of a number.

Method of Math

Static

Implemented in: JavaScript 1.0, NES 2.0
ECMA Version: ECMA-262

[edit] Syntax

Math.sin(x)

[edit] Parameters

x 
A number.

[edit] Description

The sin method returns a numeric value between -1 and 1, which represents the sine of the argument.

Because sin is a static method of Math, you always use it as Math.sin(), rather than as a method of a Math object you created.

[edit] Examples

[edit] Example: Using Math.sin

The following function returns the sine of the variable x:

function getSine(x) {
   return Math.sin(x)
}

If you pass getSine the value Math.PI/2, it returns 1.

[edit] See Also

acos, asin, atan, atan2, cos, tan