29. So meta I can't take it


#1

Could someone please help me out? I've been struggling for hours now. And pretty sure i'm just missing something very stupîd. Or if someone could at least give me a very good hint, that would be appreciated ;p

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

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


#2

Hi @jhonnietz!
You forgot to put typeof infront of Object.prototype.prototypeType. I made that mistake at first and i found out in a few minutes. Here's what your code should look like:

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

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

Glad to help you out!


#3

To be honest, it is exactly:
// 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);


#4

My code was correct, but didn't print anything and let me go to the next lesson. I literally copied the answer and just pasted it in because I don't even begin to understand what they are trying to teach me.

Can anyone explain what I'm supposed to be understanding with this and/or what I'm meant to see printed at the end?


#5

My take as a beginner who understood the concept but struggled with the code:

the first console.log tells you that Object.prototype is an object
the second tells you that Object.prototype does indeed have the hasOwnProperty property.

They're pointing out that all plain objects inherit hasOwnProperty as a property from Object.prototype


#6

That's pretty interesting. So the universal JS Object has a property called prototype which is an object itself that has the method 'hasOwnProperty' which checks to see whether an object has a property or not. I tried to see all the values of the object, Object.prototype, by running a for-in loop but nothing showed up. I wonder why?

for(var value in Object.prototype){
console.log(Object.prototype[value]);
}


#7

Thank you very much, jacoobson.
It was interesting for me.
I copied your code and it worked.
I had Written:
var prototypeType = typeof(Object.prototype);
instead of
var prototypeType = typeof Object.prototype;
And my code didn't work.
anyway, thank you so much.


#8

I did the same thing .Can somebody explain why typeof (Object.prototype) didnt worked?


#9

@microwhiz78645 my guess would be that the syntax is wrong (maybe a metaphorical comparison could be a grammatical error in non-programming language?).

A further guess (this time I'm really far out on this limb) is that maybe typeof (thing) seems like you want the typeof of () which typeof won't "read"...?


#10

No ,that actually returns Object , however , i cant complete the excercise


#11

@microwhiz78645 That's funny, I've tried typeof ();, typeof (;, and typeof ; and all give me syntax errors.

however , i cant complete the excercise

Have you created a post with your code and error message?


#12

I mean i couldn;t complete with typeof(Object.prototype) instead of typeof Object.prototype


#13

Oh, okay yes. I think the parser(?) would flag that.


#14

A post was split to a new topic: Can you help me please , with bleep bleep


#16