So Meta I Can't Take It - theory?


#1


Hey friends!


Question about this exercise: https://www.codecademy.com/courses/objects-ii/5/3?curriculum_id=506324b3a7dffd00020bf661#

I've resolved the exercise and my code is running correctly, but I am having some trouble with the theory/concept behind this exercise.

  1. What is object referred to in Object.prototype? We never created a new object here so where did this object come from?
  2. What is accomplished by adding .prototype to Object?
  3. Why do we pass "hasOwnProperty" as an argument in Object.prototype.hasOwnProperty?

Would love some help here. Thanks!


// what is this "Object.prototype" anyway...?
var prototypeType = typeof Object.prototype;
console.log(prototypeType);

// now let's examine it!
var hasOwn = Object.prototype.hasOwnProperty("hasOwnProperty");
console.log(hasOwn);


#2

if we look at this documentation, we can see that Object is a constructor. (which is part of JavaScript)

we want to see what type prototype is, which is why we use typeof

.hasOwnProperty() is a method to see if an object has a certain properties/methods, we look if prototype has a property/method called hasOwnProperty, which it has


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.