I have know that Math is an Object in javascript, however in the book it says when use the Math Object, we do not need to use the new keyword.For example,
var pi = Math.PI;
alert(pi);
I want to know why it does not need, and in other Object, like Date, it needs the new keyword.
typeof Math --> "object"
typeof Date --> "function"
Math is an Object and Date is constructor function.
new key word is used to initialize an instance with a constructor function not with objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With