Since your example is a built-in function of type Object, and, as indicated above, it is similar for this type, it does not work in the same way for most other built-in functions, such as Number (). You must be very careful when calling them with the keyword "new" or not. Because by default the keyword 'new' with the constructor of the function returns an object, not a primitive type directly. Thus, you cannot, for example, check the strict equality of two variables, one of which is declared and assigned using new Number() , and the other with Number()
An example would be:
var num1 = Number(26); var num2 = new Number(26); num1 == num2;
You can check the difference in the console log:
console.log(num1); > 26 console.log(num2); > Number {26} > __proto__: Number > [[PrimitiveValue]]: 26
source share