The Math object does not have a prototype property, but does have a constructor property. Is there any case in which redefining the constructor would be useful?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
MDN says:
In other languages, when a class is static, you can directly use its properties and methods without creating an instance of that class ( an object ). If Math constructor is used, there is no native type to support the object, unlike with the primitive types: Number, String, Boolean. They can be converted to objects with their wrappers.
Furthermore it is a bad practice to extend a root object. If in the future new functionality is implemented in the environment and the code don’t have fail-safety check for this, it will override the native one.
My personal opinion is that you do not constructor, nor prototype – you can define your own mathematical functions. The Math object is here just to present a standard functions, and give programmers the leverage not to define
PiorE, for example. And probably user defined mathematical function will be several times slower than the built-in.