1

According to w3school Every JavaScript object has a prototype. The prototype is also an object.

But let's examine this:

var SomeObject = { name: "foo" }
SomeObject.prototype // Undefined although its an object

I'm aware of __proto__ that it has

function SomeFunction () {

}
SomeFunction.prototype // object

But

var SomeOtherObject = new SomeFunction()
SomOtherObject.prototype // undefined but its is an object 

Which contradicts w3school statement Every JavaScript object has a prototype. The prototype is also an object

Any idea why?

ashwintastic
  • 2,262
  • 3
  • 22
  • 49
  • 1
    `prototype` and `__proto__` are different things. What the sentence _Every JavaScript object has a prototype. The prototype is also an object_ is referring to is `__proto__` or prototype object whereas `prototype` is a property of constructor functions which points to the object which will be used as a prototype object while constructing objects using `new` operator. It's slightly confusing. I suggest you to read a good documentation like [MDN](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype) . W3schools are not good enough – abhishekkannojia Jul 17 '17 at 08:23
  • See the linked question's answers, the `prototype` property is not the prototype of an object. There is no special significance to the `prototype` property on ordinary objects. `prototype` is only defined for functions: It refers to the object that will get assigned to objects created when you use that function with new. To get the prototype of an object, use `Object.getPrototypeOf(theObject)` (or, on web browsers only, you can use the `__proto__` property, but not all objects will have it as it's defined by `Object.prototype` and not all objects inherit from `Object.prototype`). – T.J. Crowder Jul 17 '17 at 08:32
  • W3Schools is wrong *(quelle shock!)* to say every object has a prototype. That was never true (the object `Object.prototype` refers to has no prototype and never has had), and hasn't been true for other objects since 2009 (ES5): `var o = Object.create(null);` The object `o` refers to has no prototype. I suggest using [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript) instead. Every site has pros and cons, and MDN is not perfect (it's community-edited), but it tends to be fairly high-quality. – T.J. Crowder Jul 17 '17 at 08:41

0 Answers0