JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Math Right Arrow sin()

sin()  Math  class method

Description

Returns the sine of a number in radians between -1 and 1.

  • Radians to Degrees - divide number by (Math.PI / 180).
  • Degrees to Radians - multiply number by (Math.PI * 180).
  • Like all class methods sin() should be used on the class rather than an instance of the class.

Syntax


Signature Description
Math.sin(value)Returns the sine of a number in radians between -1 and 1.

Parameters


Parameter Description
valueThe value you wish to find the sin() of:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.

Examples

The code below displays sin() usage.


// Store results in an array.
var sinValues = new Array(5);
sinValues[0] = Math.sin(-1);
sinValues[1] = Math.sin(0);
sinValues[2] = Math.sin('0.75');
sinValues[3] = Math.sin('a string');
sinValues[4] = Math.sin();
sinValues[5] = Math.sin(null);
alert(sinValues);  

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math



  

go to home page Homepage go to top of page Top