This Week in L2Code: Execution Stack

David Clark
L2Code
Published in
4 min readJan 4, 2018

Listening: The Magic Lantern
Drinking: Spring Tieguanyin Oolong from Master Zhang

Well, these last couple of weeks have been nuts! Of course, we had the holidays, which were great! Spent just the right amount of time with family, had a reasonably luxurious Christmas, and enjoyed fireworks from our living room window.

I’ve also been enjoying some wonderful teas, and I’ve discovered a new musician that I’m very much into. Can’t ask for more than that!

Then, there’s the coding. Despite the holidays, I’ve been at my laptop every day hammering out lines of code. Admittedly, I’ve hit a few snags. As I mentioned in my previous post, I was working through this Udemy course. When I got to the JavaScript portion, however, I quickly found that the instructor chosen for that section was not suitable for me. That is, I wasn’t picking up the concepts the way he was teaching them. Frustrated, I looked around for answers, including going through an install fest with Ruby, and considered doing one for Python, in attempts to refocus on something other than JavaScript.

I understand, though, that JavaScript is essential in web development. It has been said many, many, many, many times before, that you should learn JavaScript first, and if not first, at least early on.

So after reading through some of these articles for the nth time, I decided to find another course, that was just JavaScript, rather than a “web dev course” (whatever that means). I remembered that I had purchased one a few months back when a huge sale was going on. It so happens that it’s the highest-rated one on Udemy. I’m hoping that doesn’t mean that it was too easy. Time will tell. I will say, though, that I’ve gotten to the section where the instructor, Jonas Schmedtmann address the concept that I had such trouble with in the other course — Execution Stack & Context.

For some reason, that way that Jonas explains it just clicks. It helps that he gave us lines of code to demonstrate the concept. I added a few lines to the code (console.log) and ran it in Chrome to see it in action, even though I was confident in my understand of its basic principles. Have a look!

var name = "John";       //globalfunction first(){        //global
var a = "Hello ";
second();
var x = a + name;
console.log(x);
}
function second(){ //global
var b = "Hi ";
third();
var z = b + name;
console.log(z);
}
function third(){ //global
var c = "Hey! ";
var z = c + name;
console.log(z);
}
first();

Now, let’s run this in our Chrome Developer console (cmd+opt+j on Mac):

Wait a minute… if we’re writing function first(); before second(); and third();, then why are we getting Hey! John before Hello John?! Because of the execution stack. Because we are calling second(); inside of first();, it moves on to second(); before completing first();, becoming the active context. The same thing happens in second();, making third(); the active context. Then we can see that in third();, there is no other function called. Once third(); finishes running, we move back to second();, and once that completes, back to first();.

This is a very crude example, but I think it will make sense if you look through it a couple of times. Better yet, try it yourself!

I am still considering attending a “bootcamp.” I’m quite unsure, though. The ones I’m considering are Flatiron’s online Web Dev course, due to the fact that it seems to include a good deal of things you would learn with a CS Degree, such as Data Structures and Algorithms. Then there’s General Assembly’s JavaScript Development course, which I am considering because a strong foundation in JavaScript is vital to front-end web development, and even some back-end development.

It’s tough to choose to spend money on something without knowing the outcomes. Will I be prepared for a Jr. Developer position after this course? Will I be prepared for a Jr. Developer position in ‘x’ amount of time if I continue learning strictly at home? What are the fundamental differences between Udemy courses and these online paid courses? Will either provide me with a strong base of knowledge without holding my hand through it?

There’s a lot to consider when starting out with coding…

--

--

David Clark
L2Code
Editor for

Mindfulness | Humans | Animals | Earth | Coding | IG: the.coffee.smith