Home » Posts tagged "scope"

JavaScript Variable Gotchas

If you’ve been programming using JavaScript for any length of time, you’ve probably run into several of the JavaScript variable scope gotchas.  You may have even been able to fix them.  But you could prevent these gotchas if you understood better why the gotchas exist in the first place.

My goal, through a series of blog post on the topic, is to make us all better JavaScript programmers.  JavaScript is no longer a toy.  Those who survive in the new JavaScript eco system will be those who understand why JavaScript works the way it does.

I’m going to approach this topic as a series of puzzles.  This will show the issue and then we can discuss why the issue exist and what to do about it.

JavaScript Variable Gotchas

Continue reading “JavaScript Variable Gotchas”

Adventures Working With Angular’s $scope

Every week when I write, I try to think back on the past week and think, “What have I learned that might be useful to others.”  Most weeks that is a pretty easy question to answer because I get most of my pleasure from learning new stuff.  But this week was different. When I sat down to write today, I couldn’t come up with a subject that couldn’t be covered with a sentence.  More of a tweet than a blog post.  It was so bad that I decided to go run the errands that are on my list and come back to it once I got home.

Evidently, that was a good move because I think I have something that will be genuinely useful.  Although I will admit that if you’ve been working with Angular for very long at all, you may have already learned what I’m about to explain.

image

Continue reading “Adventures Working With Angular’s $scope”

JavaScript Scope

ppl-men-060

If you’ve been programming in any other environment than JavaScript for a while, you may be making assumptions about JavaScript Scope that just aren’t true.  One of those assumptions is how variables get evaluated when you run the JavaScript code and what variables are visible and at what point in the code they are visible.

Just as a test to see how well you know your JavaScript, let’s create a few tests scenarios.

Continue reading “JavaScript Scope”