Built-in Objects

Hello friends, I have this confusion:

This is what javascript.info says about built-in Objects in a summary:

"All built-in objects follow the same pattern:

  • The methods are stored in the prototype ( Array.prototype , Object.prototype , Date.prototype , etc.)
  • The object itself stores only the data (array items, object properties, the date)"

I know that for example. JavaScript have Object(), wich is the constructor function for objects instances, and Object.prototype, wich is the prototype for all the object instances of the constructor Object() where they inherent methods.

But what is exactly the “Object itself” that only stores the data (array items, object properties, the date)? It is the constructor function? Or it is something else I am missing?

Please help me to see this

It’s a bit hard to explain since it’s abstract thinking you will need to do here. Try to think like a computer and not as a human being here.

This is mixup of two different concepts and that’s probably the origin of your confusion. Array, Object and Date are not built-in objects, it’s fairly easy to verify:

console.log(typeof Array); // "function"
console.log(typeof Object); // "function"
console.log(typeof Date); // "function"

They are built-in constructor functions, aka classes. We need them to create instances of Array, Object or Date and instances would be objects, but not built-in, because you have created them and you can remove them.

Constructor functions have 2 types of methods:

  1. Prototype: stored in Constructor.prototype
  2. Static: stored directly on the function

Prototype methods are shared with all instances of that class and only constructor functions can have prototype:

const arr = new Array(1, 2, 3); // [1, 2, 3]
arr.hasOwnProperty('prototype'); // false
Array.hasOwnProperty('prototype'); // true

// Reference to constructor
arr.constructor === Array; // true
arr instanceof Array; // true
arr.constructor.name; // "Array"

Awesome response, solved, thanks!