29/30 So Meta I Can't Take It!


#1

This topic really confusing me. I am not sure how to proceed with this. Please help me in this.

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

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


#2

The instruction states

Let's first see what type Object.prototype is. Do this in line 2 and save it into prototypeType.

So you are finding the type of Object.prototype and remember the O has to be capital check that for everything


#3

Yes that capital check passed the script. :blush: simple change but impacts a lot :smile:


#4

try this out!

var prototypeType = typeof Object.prototype


#5

What does my head in with some of these Codecademy examples is the way they name some of these components. It creates confusion in my brain when all of the parts of the code look the same. I see all these prototypes and Types and Owns and I struggle to understand this:

var prototypeType = typeof Object.prototype;
console.log(prototypeType);

var hasOwn = Object.prototype.hasOwnProperty("hasOwnProperty");
console.log(hasOwn);

Yet this makes perfect sense:

var banana = typeof Object.prototype;
console.log(banana);

var bacon = Object.prototype.hasOwnProperty("hasOwnProperty");
console.log(bacon);

The examples are not helpful - I waste so much time trying to decipher what they are asking me to do because the text they are using I can't relate to.


#6

Great point, some of the earlier examples included seemingly intentional stumbling blocks in the naming conventions. I'm sure they weren't really intentional, but the extra step of deciphering names does make the exercises infinitely more challenging for beginners like myself.


#7

This line:

var hasOwn = object.prototype.hasOwnProperty("hasOwnProperty");

You need to capitalize object:

var hasOwn = Object.prototype.hasOwnProperty("hasOwnProperty");


#8

For what it's worth, I agree with you.


#10

they should give you a job writing their examples. thx. that was really helpful


#11

so what does hasOwnProperty do?
can you point to a explanation of why it exists and where and why it is used.
it seems as this is something that just should make sense and is glossed over without a explanation. that is for a beginner, using this course as a introduction to Javascript.


#12

I used parentheses in line 2 because typeof is acts like a function (i.e., it's passed an input and returns an output).
var prototypeType = typeof(Object.prototype);

The console showed that everything worked as expected, but the system didn't accept my answer until I removed the parentheses. I hope the new JavaScript class gives warning messages for these cases of doing something that makes sense and works the exact same way, but which is technically wrong and not accepted by Codecademy.

Edit: Some research brings up http://w3resource.com/javascript/operators/typeof.php, which says the following:

What is the difference between typeof myvar and typeof(myvar) in JavaScript?
There is absolutely no difference between typeof myvar and typeof(myvar).

So apparently the parentheses were merely redundant and not wrong.


#13

strong point, often the wording totally throws me, then I'll come into the forum and it makes waaaay more sense. Good thing they've got the forum i suppose, good net for catching anything we all don't understand