How to deal with brng.toRad is not a function

I am using toRad () function in javascript as below

var alpha1 = brng.toRad(); 

but when I run my code, it gives an error message: "brng.toRad is not a function"

How does this work in a java script, do I need to import some library ???

0
source share
2 answers

You can also do this:

 Number.prototype.toRad = function () { return this * Math.PI / 180; } var oneeighty = 180; console.log( oneeighty.toRad() ); // 180 degrees = Pi radians 
+4
source

Native javascript does not have a toRad function. Or

1) toRad was defined by google-maps somewhere, and brng just points to the wrong object (maybe null ?)

or

2) You need to determine the method yourself

 function toRad(degrees){ return degrees * Math.PI / 180; } toRad(180); 
0
source

Source: https://habr.com/ru/post/1490904/


All Articles