JavaScript Object Fields

Last week as I was discussing the basics of JavaScript Objects, I kept referring to the members of the object as “fields.”  Never did I call them properties or methods.  This is because all members that are hanging off of an object are treated the same, from a membership perspective.  It is the type of data it contains that makes it behave as what we would normally refer to as a property or a method.

This is an important distinction. In a strongly typed system, we can say that a member of our object is a property or method simply because it was defined as one or the other when we defined our class.

In JavaScript we have neither classes where we can define what something is, nor strong typing. So, how something functions is determined by the type of variable it is pointing to at run time.

JavaScript Fields

Continue reading “JavaScript Object Fields”

JavaScript Objects — What You Don’t Know CAN Hurt You

I’m assuming that anyone reading this blog has probably been using JavaScript for a while.  Many of you have used a number of the many frameworks that are available and most have used jQuery.  For the most part, you get what needs to be done, done.

But, I would also say that most of you have no idea how JavaScript works.  This is why I’ve written about JavaScript Variables, JavaScript Functions, and now JavaScript – Objects.

So, let’s start with the most basic of JavaScript questions.

image

Continue reading “JavaScript Objects — What You Don’t Know CAN Hurt You”

Angular 2 – First Impressions [Compared to Angular 1]

I’ve spent the last week putting together a reference app for Angular 2.  It is a great exercise to try to nail down the basics of how a new framework works.  Next week I plan on doing a similar exercise for React.

Anyhow, I thought for this week’s post, I would try to relay some of my impressions, and some of the issues I see with this new framework.

Angular 2 - First Impressions

Continue reading “Angular 2 – First Impressions [Compared to Angular 1]”

JavaScript Functions — In-Depth

Last week I talked about JavaScript variables gotchas.  This week, we want to take an in-depth look at JavaScript functions.

Why?

Well, for the same reason we looked at variables last week.  If you keep using JavaScript the way you think it works instead of the way it really works, at best, you will have a much harder time debugging your JavaScript code.  Worse case, you introduce some pretty nasty bugs into your code.

So, let’s start with a pretty basic JavaScript function question.  One I would use as a question if I were interviewing someone for a hard core JavaScript job.

What is the difference between the following two ways of declaring a function?

function foo(){
}

var foo = function(){
}

JavaScript Functions -- In-depth Continue reading “JavaScript Functions — In-Depth”

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”