Languages
[Edit]
EN

JavaScript - Math.cos() method example

15 points
Created by:
lena
714

The Math.cos() function returns the cosine of the specified angle in radians in the range -1 to +1.

Note: 6.123233995736766e-17, -1.8369701987210297e-16 and 6.123233995736766e-17 should be equal to 0 but they are not because of computation precision error.


1. Documentation

Edit
SyntaxMath.cos(number)
Parametersnumber - integer or float number value in radians (primitive value).
Result

returns a numeric value between -1 and +1, which represents the cosine of the angle (primitive value).

Descriptioncos is static method that takes only one parameter and returns approximation of cos(x) mathematical function result.

2. Working with radians

Edit

3. Working with degrees

Edit

4. Reversed console plot example

Edit

5. Canvas plot example

Edit

References

Edit
  1. Cosine - Wikipedia

Alternative titles

  1. JavaScript - Math.cos() documentation with examples
  2. js - Math.cos() method documentation with examples
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - Math.cos()

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join