Are primitive types in JavaScript objects?

Is 𝗲𝘃𝗲𝗿𝘆𝘁𝗵𝗶𝗻𝗴 in JavaScript an object? I see many developers say that, but that's not accurate. Primitive types essentially aren't objects, although they behave like. Each primitive value has its own wrapper object. When you run some operations like .𝘁𝗼𝗨𝗽𝗽𝗲𝗿𝗖𝗮𝘀𝗲() on a string, or .𝘁𝗼𝗙𝗶𝘅𝗲𝗱() on a number, the engine immediately creates a wrapper object to make it possible. The object is discarded right after the operation completes, and it returns a new value (without changing the original value), since primitive values are immutable. This process is called Autoboxing. #javascript #techinterview #interview

  • text

To view or add a comment, sign in

Explore content categories