Summary
Returns the sine of a number.
Method of Math |
|
|---|---|
| Implemented in | JavaScript 1.0 |
| ECMAScript Edition | ECMAScript 1st Edition |
Syntax
Math.sin(x)
Parameters
-
x - A number (given in radians).
Description
The sin method returns a numeric value between -1 and 1, which represents the sine of the angle given in radians.
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.
Examples
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.
Mozilla Developer Network