Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialrobinbehroozi
15,912 PointsWhy is the Javascript Prototypes example so complicated?
So, I recently passed Javascript Foundations, but when I look over the videos, I found the Prototypes section really complicated.
When I searched online, I found a much easier way to make objects in Javascript.
This is the example I found…
function person(first, last, age, eyecolor){
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eyecolor;
}
var myFather = new person("John", "Doe", 50, "blue");
So person is the constructor function….
Is this a better way to create objects in Javascript, or is Jim's way ok too?
8 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsI think it;s better in that it uses more arguments and applies them to the .this keyword. I'm eager to explore more examples of Prototype Objects on Javascript but in Jim;s example I think it's good because it explores more concepts in Prototypes than the above example.
parminder bhatti
764 PointsHi. With respect that does not answer the problem.
Objects and prototype is clearly a much more complex area when weighted against the other areas. Wouldnt it be better to have numerous sections with lots more examples and tasks. To make this concept stick in our brain for us learners.
its been a great video course but just lacked in this objects area. I still don't feel I know them.
Phyllis Beck
4,537 PointsI agree, Object oriented javascript is in itself a broad topic and it would be wonderful if Treehouse could do a course focused on it and other complex topics such as Recursion. Of course I also wish they didn't teach code in a way that is so abstracted from how it would be used in a project based setting. The new foundations of javascript course does a better job but it doesn't get as in depth as this course. I have found that finding a tutorial that actually teaches me to build something while also teaching the code syntax to be the most effective way of learning.
daviem
21,118 PointsI would tend to agree with this also. Don't get me wrong I think these basics foundations courses are excellent and obviously useful: for me anyway it's a far more effective way to learn than reading textbooks. But I think treehouse is short on courses that do what, for example, Randy's PHP course does so excellently (excluding the annoying frog :D ) , building an online shop at the same time as teaching PHP; for me its the most effective and satisfying way of learning.
parminder bhatti
764 PointsThanks Phyllis
I agree, i feel I am learning little nuggets of information but never enough to actually take on something a little more chunky. We really do need some "real world examples". Stop using console.log except where you need it and start developing something.
I will check out the "foundations of javascript" then.
It would be nice to hear what TeamTreeHouse.com themselves think about this feedback. Are they aware of it and are they considering responding to it.
Danny Luna
5,899 PointsI have to agree these last 2 videos are frustrating to say the least, I've been looking elsewhere for better explanations!
Joe Williams
4,014 PointsI have to agree with everyone else here. Of every video thus far in the series, Prototypes and Objects felt the most rushed and complicated. It's hard to grasp what's happening when there is no real world application to what's happening. This is the first time I'm finding myself looking elsewhere to get better examples and clarification.
Niki Brown
Courses Plus Student 1,056 PointsI also found this explanation of prototypes much better than the video: http://sporto.github.io/blog/2013/02/22/a-plain-english-guide-to-javascript-prototypes/
Abdi Ahmed
7,151 PointsYes, the videos and challenges on prototypes are a bit confusing. But what I found out is that there are different ways to accomplish the same thing in JavaScript. And this can be confusing! Because the way Jim is using and explaining a prototypes is one way, and there are other ways that you can use prototypes. I would definitely recommend that you use an extra resource to understand these videos and the challenges, one resource that I found helped me understand was the section on objects in http://www.codecademy.com/en/tracks/javascript - I recommend going through the exercises on Objects I and Objects II, then come back rewatch the videos and attempt the quiz.
Hope this helps if you're having trouble understanding.
A Abbara
Courses Plus Student 1,982 PointsA Abbara
Courses Plus Student 1,982 PointsThe 'prototype property' is useful when you want to change all instances of an object.
Say you wanted to add a property to all your 'person' objects. If you had a person called myFather and one called myBrother and one myMother etc, you'd need to individually set their property (myFather.property = xyz; etc. If you had a family of say 20 persons, you'd need to individually set all their properties!)
But using the prototype property, you simply write:
person.prototype.property = xyz;
Now it's changed for all instances of the person object. I agree that for me, the prototype videos were the only confusing ones out of the entire JS series.