object wrappers are objects that encapsulate primitive data types (such as numbers, strings, and booleans) and provide them with additional methods and properties.
These wrappers allow you to treat primitive values as objects, enabling you to access and manipulate their values more conveniently.
All primitive types, except null and undefined, have their corresponding object wrapper types,
When you try to access a property or method on a primitive, JavaScript temporarily wraps that primitive in a special object so you can use its powers.
The Trigger: You call .toUpperCase() on a string.
The Wrap: JavaScript creates a temporary String object: new String('gemini').
The Execution: It runs the method on that object and returns the result.
The Cleanup: JavaScript immediately throws the object away (garbage collection) to save memory.
Performance: Objects are heavy. Primitives are 'passed by value' and stored directly on the Stack. Primitives are lightning-fast and memory efficient.
Objects are stored on the Heap, require memory addresses (pointers), and consume more resources.
By using wrappers, JavaScript gives you the speed of primitives with the functionality of objects only when you actually need it.