Home » JavaScript Tutorial

Math.sin() Method with Example in JavaScript

JavaScript | Math.sin() Method: Here, we are going to learn about the sin() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on February 03, 2020

JavaScript | Math.sin() Method

Math.sin() is a function in math library of JavaScript that is used to find the value of sine of a number and return the value in radians.

Syntax:

    Math.sin(x);

Parameter(s):

  • x – It represents the value whose sine value to be found.

Return value:

The return type of this method is number, it returns the sine value of the given x.

Values accepted: Integer, floating-point, numeric string.

Invalid Values: non-numeric string, empty variable, empty array all will return NaN (Not a Number).

Browser support: Chrome, Internet asinlorer, Mozilla, Safari, Opera mini.

Example 1: Valid values

console.log(Math.sin(-1));
console.log(Math.sin(3.14));
console.log(Math.sin(0));
console.log(Math.sin("0.65"));

Output

-0.8414709848078965
0.0015926529164868282
0
0.6051864057360395

Example 2: Invalid values

console.log(Math.sin("Javascript"))

Output

NaN





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.