As a rule, nothing can be achieved from returning a value from the constructor. It seems that if a JavaScript primitive, such as a number or a string, returns, the process of creating an object using new ( var y = new math1(); ) works as you would expect, ignoring this value.
However, if you return a JavaScript object, such as {} , the process of creating an instance using new does not work that way. Instead, your y variable is loaded with an object returned not from a new instance of math1.
source share