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 trial

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Methods with Prototypes

Jared Hensley
Jared Hensley
8,106 Points

Some input

I feel like this course could be greatly improved. The last few seconds of this video are telling. Andrew states that it took him awhile to be able to explain these concepts, and that it is okay if you don't understand them. I completely understand because this stuff is difficult to talk about in words at times. I think the problem is that he needs to spend more time breaking down subtle concepts instead of using console.logs and leaving it at that (basically assuming the student knows what just happened). It's easy to predict that this is the outcome you want, but we are not focusing on why and things are very scantly run through. It's also very hard to follow without being played at .5x or .75x speed (which is tough to understand). Normally, I play the videos at a min. of 1.1x to 1.25x. I think this series needs to have some additional footage spliced in that further explain some of the fundamental concepts. I love Treehouse so I hope you don't take my input personally, I do appreciate all you have provided for the community.

2 Answers

Kayla Stone
Kayla Stone
3,709 Points

That is exactly how I have been feeling about all the JavaScript courses up to this point! The HTML and CSS courses were a lot easier to understand because I think they are much more intuitive and just make sense. I have been feeling very lost and completely agree that they should explain the concepts more thoroughly, it's hard to know when to use certain inputs if you don't understand why you should. I just wanted to say thanks for sharing your opinion and I am glad to see that I'm not the only one that feels that way.

Joshua Erskine
Joshua Erskine
7,706 Points

I agree this course could have done with a lot more background and a few graphics.

For those interested below are some notes, and a review of Chalkey's code I found useful for understanding prototyping.

The code: (I have simplified random out of haste, apologies)

//-----  1. Everything in a single function ------------------//   
    function Dice(sides){ 
        this.sides = sides;  
        this.roll = function() {
            var randomNumber = 100 + this.sides; 
            return randomNumber;} 
    }
//-------- 2. Two functions, both universal  ------------------//
    function diceRoll(){   //Problem is anyone can access this function
        var randomNumber = 100 + this.sides;
        return randomNumber;
    }

    function Dice(sides){ 
        this.sides = sides; 
        this.roll = diceRoll;
    }
//------ 3. Single function with an appended prototype --------//
    function Dice(sides){   
        this.sides = sides; 
    }
    Dice.prototype.roll = function (){
        var randomNumber = 100 + this.sides;
        return randomNumber;
    }

My Notes:

  • Functions almost "always" have an attached Object
  • The new keyword generates an Object from a Function:

https://www.anony.ws/i/2016/01/12/Treehouse1and2.jpg

https://www.anony.ws/i/2016/01/12/Treehouse3.jpg

Hope this helps someone.

For those looking for more resources please note:

  • a prototype , function.prototype [that is functionName dot prototype], and .__proto__ [double underscore proto double underscore] are all different things.
  • there are a few different schools of thought regarding JS code structure: Classic/Class based inheritance vs Prototypal/Object based inheritance.