JavaScript Asynchronous Programming with JavaScript Understanding Promises From Callbacks to Promises

Nicolas Valdivieso
Nicolas Valdivieso
6,654 Points

Why are constructors used in this video if they haven't even been introduced?

i personally know constructors bc i had previous experience but it makes me wonder what about the ppl that are joining this course with no previous experience on javascript.

Michael Cook
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Cook
Full Stack JavaScript Techdegree Student 25,996 Points

No one should be taking a course like this without having a solid foundation in the basics. This course will be virtually useless to them without having experience.

4 Answers

Steven Parker
Steven Parker
201,932 Points

This is an intermediate level course, and is not a good starting place for anyone who has no previous experience in JavaScript.

Anyone learning JavaScript for the first time might find the Beginning JavaScript track to be a more suitable way to get started.

Robert O'Toole
Robert O'Toole
6,333 Points

i still don't think ive ever been introduced to constructors in the front end track. luckily i know what they are but there seems to be a big jump in expected knowledge at this point even after taking the beginner courses in front end.

Michael Cook
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Cook
Full Stack JavaScript Techdegree Student 25,996 Points

I just had a look at the FEWD track. It looks like the course Object-Oriented JavaScript actually comes after courses on AJAX and Asynchronous Programming, which is a major oversight. Object Oriented programming is a particular way, or paradigm for programming in which the major components of a program are composed of objects, which have methods (functions attached to the object) and properties (variables encapsulated in the object). A lot of the things you're working with in asynchronous programming, like the XMLHttpRequest object and promises are objects. Objects are made out of classes, which are like blueprints that can generate as many instances as you want, you simply use the constructor for the class. E.g:

class Cat 
{
    constructor(name) 
    {
        this.name = name;
    }

    sayHello() 
    {
        console.log(`Meow, my name is ${this.name});
    }
}

const fuzzy = new Cat('Fuzzy');

fuzzy.sayHello();
// Meow, my name is Fuzzy

This is just a really basic tutorial. You should probably take the Object-Oriented JavaScript course and then the Object-Oriented JavaScript: Challenge course before doing anything else. These two courses will definitely challenge you, but take it at a comfortable speed and be patient. At the end you will have leveled up as a developer.

You might also want to let the Treehouse staff know about the OOP not being taught at the correct point in the track. Good luck!

Michael Cook
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Cook
Full Stack JavaScript Techdegree Student 25,996 Points

My last comment might not have made one point clear. The constructor is the function you call to instantiate a class, or in other words, create an object from the class. And again, the class is a blue print for the object. So you write:

new Cat('Fuzzy');

The new keyword lets JavaScript know you're making a new object from the class. You can do this with things like arrays, for instance. Arrays are just a kind of object. Usually people use array-literals [1, 2, 3] but you could write:

const myArray = new Array(1, 2, 3);

myArray;
// [1, 2, 3]

Everything in JavaScript pretty much is an object and can be worked with in this sort of way, though for a long of things its not convenient and literals work better.

Roald Jurrian Kamman
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,525 Points

Thank you Michael Cook for pointing that out! I was struggling with all the strange syntax and some other things I can't really define because I haven't seen them before. It makes sense that I'm missing a piece. Will put this on hold until I'm finished with the object-oriented javascript.

Addy Grothues
Addy Grothues
Full Stack JavaScript Techdegree Student 11,047 Points

In the Fullstack Techdegree, they were introduced in the OOJS bit: https://teamtreehouse.com/library/objectoriented-javascript-2

Not sure about other courses though...! If you think there's a disconnect in the tracks/courses, you should provide that feedback to support.