Getting Started with JavaScript for Web Development: Lesson 9 of 23

Objects

Up Next

Built-In Objects

Autoplaying in 7 seconds!

Cancel

More Details on Objects

When I state that "everything is an object", that is an oversimplification. A more apt description would be:

Everything can become an object.

There are primitives (strings, numbers, and booleans) and objects (String, Number, and Boolean). For instance:

Table of Contents

    
    // primitives
    const primitiveString = 'my string';
    const primitiveNum   = 47;
    
    // objects
    const myObjString = String('my string');
    const myObjNum   = Number(47);

    JavaScript has the ability to convert on the fly from the primitives, to the objects, and back to the primitive when the need arises.

    JavaScript will wrap the primitive in its object counterpart so that we can use the methods like .toLowerCase().

    Chris Sevilleja

    173 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.