The full video and many others like it are all available as part of our Frontend Masters subscription.

Kyle Simpson

Kyle Simpson is an Open Web Evangelist from Austin, TX, who's passionate about all things JavaScript. He's an author, workshop trainer, tech speaker, and OSS contributor/leader.

Kyle Simpson

You Don't Know JS

Kyle explains the scope of this course. He will focus on the "what you need to know" parts of JavaScript. This includes coverage on Scopes, Closures, Object Oriented Coding, and Asynchronous Patterns.

Get Unlimited Access Now

Kyle Simpson: So I'm going to give you, this not the official title, but this is kind of the unofficial title for todays. This is a two day workshop, this is the unofficial title because, this is what I give when I give this one day talk is a standalone. I call it the What you need to know Parts, Advanced JavaScript, The What you need to know Parts.

And I need to explain to you what my practice is going to be. You should already get a flavor from that just from our discussion of looking at the spec. But I want you to understand what you should be expecting from today. So first of all I call it Advanced JavaScript.

Does that mean that I expected you to be an advanced JavaScripter before walking in here, before joining online? No, that's not what I expect. What I do kind of recommend is that you're taking this course with at least maybe one to possibly two years of experience with JavaScript.

And that's not a requirement, it's just a recommendation that you at least be familiar with the language. So we could call that sort of somewhere between beginner and intermediate in terms of your experience, kind of your base experience. I'm not going to teach you how for loops work, I'm going to expect that you understand stuff like that.

But I am going to take things which you might consider to be basics. Things like lexical scope, which you just sort of, maybe you never heard it called that, but you just sort of understand kind of intuitively. We're going to take that stuff and break it down into extremely deep detail.

I'm going to give you compiler terminology here in a few minutes. And that may feel a little uncomfortable, because some of us aren't quite like me. I write compilers for fun, but not everybody does that. So understanding that kind of deep terminology and concepts can be difficult. And so when I say Advanced JavaScript, it really is kind of the advanced basics.

We're going to take the basic things that I think are requirements for you to understand before you can be an Advanced JavaScripter. There's a whole bunch of stuff that you could spend ten or more years in this industry writing JavaScript and never actually understand. And there's a lot of people that will attest to that.

I've written JavaScript for a decade and I didn't understand how closures work. It's just a fact, because JavaScript's so approachable, it's so easy to get up and going. And you can spend your entire career never being forced to actually learn it. I'm going to force you today to actually learn how that stuff really works.

So some people would define Advanced JavaScript as broad as possible. Let's look at every possible acronym and framework and hot pattern of the day and let's talk about all these possible things. And there's lots of great courses, Marc's got lots of great courses and there's lots of other great content out there.

Infinite numbers of blogs and books that talk about that sort of stuff, that's not what today is. Today is going to be a very narrow scope of what we're going to discuss, but we're going to go extremely deep with it. We're going to dig our teeth deep into this stuff, so that's what I mean by advanced.

And when I say the what you need to know parts, obviously I'm making a play off of Crockford's The Good Parts. But when I say the what you need to know parts, I'm going to explain to you when we talked about the this keyword. Or when we talk about the definition of what closure means.

I'm going to explain to you in what I hope is more understandable terms than just quoting to you the spec. I'm not just going to show you a bunch of screenshots of what the spec says. Although I think it's important to be aware of what the spec says, so that you're not saying things incorrectly.

My focus here is to give you practical takeaways on things, so this is the what you need to know definitions for these things, rather than necessarily the academic ones. There will be people that will disagree with me and say no, no, no, that's not a type. Or no, no, no, that's not really accurate about closures.

And my answer to that is to just shrug and say, well. I'm not interested in being academically formal, I'm more interested in giving us practical understanding.
Kyle Simpson: Okay. So, without any further ado, this is going to be our first discussion. Point we're going to spend a good portion of the morning talking about scope and closures.

So we're going to start by talking about Nested Scope, we're going to move into a discussion of Hoisting. May or may not of ever heard of what hoisting is. Now I'm going to do something kind of interesting, because if you don't understand anything about these mechanisms. It should seem strange to you that third item on the list, when I talk about the this keyword.

Sort of injected right in the middle of the discussion about lexical closures. Maybe that seems weird, maybe it doesn't. If it doesn't seem weird to you, I hope it does seem weird to you by the time we get there. Because the point is actually that these are completely opposite mechanisms.

So the reason I stick it right there in the middle is to make it really obvious, the contrast, the difference between them. So this is an unusual approach. In the books, I didn't deal with a this keyword inside of the scope in closures because my editor was like, no, that's too weird.

But when I'm doing training, I can do whatever I want and I think it's better to talk about it there, so that we can contrast. So that's intentional that it's kind of weird, but then we'll jump right back into a discussion of closure. And I should also say, there will be a fair amount of lecturing.

I'm going to do a bunch of talking and thing's like that, but there is also as you know, there are five exercises. Each one of those is designed to be anywhere from seven or eight minutes up to fifteen minutes of free time that you're working on something. Or I give you the exercise, I give you some time to work on it.

I shut up for a little bit and then I come back and kind of give you a guided solution tour if you will, kind of how I would approach things. There's no right answer to any of this stuff, but I do provide in each one of those exercises, a fixed version of the files that gives you my example of how I would have done it.

So at a later time you can come back and say, well how did Kyle do it? But that doesn't necessarily mean that's the only way to do it, so there will be exercises for you to do. Now if we contrast that to what we're going to deal with tomorrow, there's comparatively a lot less lecture tomorrow and a whole bunch of just hacking at the code terminal.

So there's very few slides, and we spend most of our time just kind of live coding, tomorrow. So if you're really looking for that code and you feel like I'm lecturing and I'm too much boring, just hold off until tomorrow. If you like the lecture stuff, there'll be plenty of that today.

The goal for today is to give you a really, really solid foundation of understanding about the core mechanisms that JavaScript relies upon. So that when we talk about scope, I mean when we talk about something inside of node.js. And I just assume that you understand what lexical scope means when I talk about a module the scope.

I'm going to assume that you understand what that means and I can't assume that today. Even if I looked at some of the responses from the pre-event surveys. Some people felt really confident with the stuff and other people are coming in with not quite so much confidence. So the goal is that everybody walks away from today with that confidence.

So that when we talk about node tomorrow, there aren't questions about those core mechanisms, we can really focus on the thing. It's kind of one of those hidden secrets about the node world. A lot of people tend to think that if you talk about a scale of one to five, like my understanding of JavaScript is a two out of five.

Then my understanding of node is two out of five and in reality, they're actually kind of skewed. You can have an understanding three, in JavaScript, out of five and you can still be at a one level understanding in node. Because node requires you to understand a whole bunch more of the language than you've ever been forced to understand really before.

Or you get yourself into trouble. So they're kind of skewed and that's why we set this up as a two day workshop. So that we can make sure that we fully understand JavaScript before we talk about node.

Ready to take your code to the next level?

Intense courses with world-class teachers and unlimited access to our growing library of videos for the great price of $39 per month.

Get Unlimited Access Now