DEV Community

Discussion on: 19 JavaScript Questions I Have Been Asked Most In Interviews

Collapse
 
merthod profile image
Merthod

Primitives are called that basically because they are represented as is in the underlying C++ code, or bytecode.

But in JS, everything is an object. undefined, for example is a property that lives in the window object of a browser. Naturally, in JS primitives are wrapped in their [forgot the ECMA-naming-convention] object. But as long as you assign a primitive to a variable or use () or return it (thus wrapping it in an object), it becomes an object on its own automatically because of the prototypical nature of the language.