Javascript - Math sin() Method

The sin() method returns the sine of a number.

Description

The sin() method returns the sine of a number.

This method returns a value between -1 and 1, which represents the sine of the parameter x.

Syntax

Math.sin(x)

Parameter Values

Parameter Require Description
x Required. A number

Return

A Number, from -1 to 1, representing the sine of an angle

NaN if the value is empty

Example

Return the sine of a number:

Demo

//display the sine value of 3.
console.log(Math.sin(3));/*from w  w w .j  a  v a 2  s.com*/

//Return the sine of different numbers:
var a = Math.sin(3);
var b = Math.sin(-3);
var c = Math.sin(0);
var d = Math.sin(Math.PI);
var e = Math.sin(Math.PI / 2);

var x = a + "\n" + b + "\n" + c + "\n" + d + "\n" + e;
console.log(x);

Result