Check out a free preview of the full Getting Started with JavaScript, v2 course:
The "Three Pillars of JS Exercise" Lesson is part of the full, Getting Started with JavaScript, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Kyle instructs students to build off of code from the first exercise by incorporating elements of types, scope and closure, and the this and prototypes system.

Get Free Access Now

Transcript from the "Three Pillars of JS Exercise" Lesson

>> Kyle Simpson: Wow, that was an awful lot of JavaScript that I just threw at you over those last few lecture videos? Well, it's good that we practice what we've been looking at so that it doesn't just go in one ear and out the other. So that's why we got this exercise to practice all those three pillars of the JavaScript language.

[00:00:17] We're gonna be practicing a little bit about types and coercion, a bit about scope and closures, and a bit about the this keyword and prototypes, specifically using that class syntax that we talked about at the end. So let me orient you to this exercise and then we'll give you plenty of time to work on that.

[00:00:34] What we're gonna be doing is revisiting the exercise from previous, but we're gonna be adding some more functionality to this now, or a little bit more sophistication to it. Now that we understand a little bit more about JavaScript. So we're gonna be defining a Bookshelf class. And you can see that there's going to be a constructor.

[00:00:52] We're going to have the addFavoriteBook and printFavoriteBooks, you might remember those from the previous exercise. Well, now we're gonna move them to be methods inside of our bookshelf class. And then we're gonna be calling a function that pretends to make an ajax call. That's a way of making a request from the webpage back to the server, and getting some information.

[00:01:14] We're not going to really make an ajax call. I've provided you a fake function that pretends to do ajax. But it's going to give you a chance to practice remembering something over time which is what we're going to do with closure. So you're going to get a chance to practice with all of three pillars.

[00:01:29] I've laid out very specific instructions. I want to make sure you go through them in order and make sure you read very carefully. You gonna try out this exercise, and bit by bit make sure you're executing this code. Don't just write a bunch of code, and then try to run it, and you have a whole bunch of errors.

[00:01:44] Every time you make a little change or a little edition, move it over to one of those JavaScript environments like runJS, or the Chrome dev tools or something like that. Make sure you run the code, and check yourself often. Make sure you save your files often so that you're not losing information.

[00:02:00] But we'll give you some time to run through this exercise and try your hand at it. And don't feel bad if there's some challenge here because this is an awful lot of JavaScript to throw at you all at once. I just want you to get a little bit of a feel, little bit less intimidation, hopefully around each of those core pillars of the language.

[00:02:18] Again, feeling okay about how we deal with types and coercion, feeling okay about the scope and the closure system and feeling okay with the this keyword and the class system.