Check out a free preview of the full JavaScript: The Hard Parts course:
The "Principles Review" Lesson is part of the full, JavaScript: The Hard Parts course featured in this preview video. Here's what you'd learn in this lesson:

Before moving on to the next unit, Will reviews Principles of JavaScript and takes questions from students.

Get Unlimited Access Now

Transcript from the "Principles Review" Lesson

>> Will Sentance: Unfortunately my slides are less, man. That thing there it says functional programming. That's meant to be like a grand bold statement on a new slide but instead it's like a little thing on the bottom. So let's imagine we're just looking at this functional programming. Here we go.

[00:00:17] We now have core Platform of JavaScript from which to learn from. We have our core platform. There it is. Our memory, where stuff gets stored. Our thread, where stuff gets run line by line. When we start running a function, remind me again, Shelby, how do I start running a function?

[00:00:37] How do I start calling a function?
>> Speaker 2: With parentheses.
>> Will Sentance: Parentheses, there it is. What does calling a function create everyone, together? It creates a brand new?
>> Speaker 3: [INAUDIBLE]
>> Will Sentance: It creates a brand new execution context. This is, believe me, this is everything. Is so powerful like this.

[00:00:57] Whenever I start calling a function, I get to create a new execution context. So how do I call a function, Lindsay?
>> Speaker 2: Parentheses.
>> Will Sentance: Parenthesis and when I call a function I create a new?
>> Speaker 3: Execution context.
>> Will Sentance: Exactly, smart room, a new execution context where we just have exactly what we do when we always run code.

[00:01:14] We have our memory, and thread but now we do it inside the function. When we start doing the code number line inside the function and our memory inside the function. What we're doing now, multiple execution context, all at the same time, but they're all around. So how do we keep track of them, cuz we're only ever in one at a time, so we gotta know which one of you're back to, etc.

[00:01:35] How do we keep track of them? Don't panic, java script has the cool stack to track which function core we're in, which execution context we're in, okay. Those are our three fundamental principles. All of JavaScript, there's no bonus features like the prototype of nature, we'll cover that tomorrow.

[00:01:53] They're no bonus features of JavaScript, but otherwise all of JavaScript can be captured by these three underlying principles. Now, we're gonna come tomorrow also to asychronus JavaScript. That introduces a couple of bonus, very significant pieces that cannot be explained by this world view. Tomorrow we're gonna see some code and try and evaluate it from this world view, this paradigm, and we're gonna go no, no, no, this doesn't capture, this doesn't capture what I'm trying to do here.

[00:02:28] There must be something else going on. We'll see that tomorrow morning. But for synchronous JavaScript, this is it. What's that, Mark?
>> Speaker 3: I wanted to ask you about, so you're saying JavaScript goes line by line but they're must be some other process to create the context and stuff ahead of time.

[00:02:45] So they're asking if there's a compilation phase or does JavaScript just go line by line?
>> Will Sentance: We maybe mentioned it before people came on, but we talked about there being an interpretation style. JavaScript nowadays actually uses what's called just-in-time compilation. The V8 engine from Chrome uses just-in-time compilation, which does all sorts of very smart optimizations around which bit of this gets assigned to memory first.

[00:03:13] But for our purposes, again that comes back to that question, going deep, going under the hood of the language, is not for theoretical purposes. It's not for our intellectual curiosity, we do it because it makes debugging, writing clean code, and communicating what we're really doing much, much more possible.

[00:03:35] But that also means we have to hit a level we go, hold on, do I need to understand how this is turned into bi-code. Well, no I don't because it doesn't have any implications for how I write my code, it doesn't help me write cleaner or more efficient code.

[00:03:50] So the question from the online audience about, how does the compilation step work here, how does the just-in-time compilation actually work? We don't need to worry about here. These are our three already quite under the hood aspects of the JavaScript run time. These are the three we need to know to effectively write, debug and communicate our code.