So Meta I Can't Take It!


#1

I just could not understand what this exercise was all about. Can someone please elaborate? What was the learning here?


#2

Hi,

I don't know why but my code works.

// 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);

Can someone explain me why and the objective of this exercise?


#3

console.log(prototypeType);
This is printing out the typeof of Object.prototype. It basically proves that it is an object type.

The second is to prove that Object.prototype has its own properties.

Now I need a codecademy moderator to explain
var hasOwn = Object.prototype.hasOwnProperty("hasOwnProperty");
Does this mean that the string value of hasOwnProperty is "hasOwnProperty"?


#4

I also had trouble understanding the purpose of the string ("hasOwnProperty") if someone can help?


#5

hasOwnProperty is a function that is a property in the Object in JavaScript, and that function checks if there is a property in a object. To clarify a bit the Object with the capital O is an already existing object in JavaScript. So when you type:

var myobject = new Object()
The Object is an existing object that has its own properties and you are making newObject inherit from Object.

I'm not 100% sure but I think that is how it works.