Skip to content Skip to sidebar Skip to footer

How Does Trig Work In Javascript?

I have a value and its cosine as: -0.2567721374914637 Cosine: -0.04253775592822526 Compare what we get in Python: >>> import math >>> math.cos(-0.256772137491463

Solution 1:

You can do this javascript like this:

//Return the cosine of a number:
Math.cos(3);
// -0.9899924966004454

You can get the full list of Math objects here: JavaScript Math Object

Solution 2:

You have the Math object:

Math.cos(-0.25)
0.9689124217106447

You can find all functions available in Math here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math

Post a Comment for "How Does Trig Work In Javascript?"