Codecademy Forums

Guide: What is an Object?

What is an Object?

In simple terms, an object is anything that can be represented by a symbol. In other words, it is something.

The absence of something will in programming languages have a name, and a representative wrapper object that acts as a stand in for that nothing. JavaScript calls it, null.

null as it turns out is the top of the JS prototype chain of Object.

But we digress.

What is an object? It is a value of any type. Hence all types trace their origin back to Object. If we can figure out objects in JS, we can do it in any language. It’s a quirk of the language, being prototypal, that it would reveal OOP properties, but it does.

1 Like

I don’t think this is completely true.

Javascript also knows primitive types. These are direct values that do not own any functionality.
In case of javascript the following types are primitive:
undefined , null , boolean , string and number

Because JavaScript will readily coerce between primitives and objects it will convert this primitive to an object as soon as it is used (source).
This does not apply for all languages tho.

This means not everything that can be represented by a symbol(variable) is an Object.

A better way of describing a Object would be: Anything that can exists, as long it’s not a primitive.

Here is some more information on the difference between a primitive and an Object.


Primitives may not be objects, per se, though as soon as we assign them to a variable they are given an object wrapper.

 > a = prompt('')   // clicked 'Cancel'
<- null
 > typeof a
<- object

No, i don’t think so.
I do not know when exactly they change to an Object but i think its when they go trough or are created by a fellow Object. The reason a is a object is because you are assigning a trough a function which belongs to an Object. It might be null at the time but since it came from an Object it itself is wrapped as an Object.

Taking the example of the source i included in my post we can see the primitive’s stay primitive unless acted upon by another object.

Here are some tests on this:

String.prototype.returnMe= function() {
    return this;
var a = "abc";
var b = a.returnMe();  
var c = 123;
console.log(a);	//"abc" 
console.log(typeof a); //"string" (still a primitive)
console.log(b); //"abc"
console.log(typeof b); //"object"

console.log(c); //"123"
console.log(typeof c); //"number"
c = c+123;
console.log(c); //"246"
console.log(typeof c); //"number"

Even after using variable c for a calculation, it still remains a primitive.

1 Like