What is the purpose of numeric / boolean / string objects as opposed to primitive values?

In javascript, you can call a function as a function or as a constructor. For example, you can:

myObject = new Number(13);
myPrimitiveValue = Number(13);

or simply

myPrimitiveValue = 13;

I understand the difference between the results. Can you explain to me under what reasonable circumstances it is desirable to create a number, logical or string as an object? For example, the ability to set new properties (this is what you can do on objects, but can't really do on primitive values) is almost always a bad idea for objects containing number / boolean / string. Why do I need a numeric / boolean / string object?

+3
source share
1 answer

.

Microsoft Number:

" Number . Number toString. . .

. . Number Number , Number ."

+1

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


All Articles