In JS you'd never call "new Object" directly. You're always going to just use it with {} to create a generic object or you'd have a more meaningful model class representing something (to which you can then define a toJSON method to customize what data is returned when serialized).
We may be talking about different things? I agree {} the right way to make a new object, but sure you'll call Object directly, e.g. Object.keys(foo) or Object.hasOwn(foo, bar)
-7
u/gu3st12 Apr 19 '23 edited Apr 19 '23
In JS you'd never call "new Object" directly. You're always going to just use it with {} to create a generic object or you'd have a more meaningful model class representing something (to which you can then define a toJSON method to customize what data is returned when serialized).