Category Archives: JavaScript

Responsible JavaScript: Using Switch

JavaScript, like most languages of the C-genus, has a switch statement which is a really handy alternative to the standard if conditional. switch is a bit of an underdog in the world of conditionals, usually only coming out when there … Continue reading

Posted in JavaScript | 1 Comment

Responsible JavaScript: Incrementing and Decrementing

One area of JavaScript which has gotten a lot of negative attention lately is the increment and decrement operators. To be clear, much (if not all) of this discussion can be traced back to JSLint’s intolerance of them. To understand … Continue reading

Posted in Design Patterns, JavaScript | Leave a comment

Talk: Responsible JavaScript

In case you haven’t noticed, I’m just past the halfway mark on my series on Responsible JavaScript. If you haven’t been following it, be sure to check it out — there’s some good stuff in there. Tonight, I’ll be giving … Continue reading

Posted in JavaScript, Talks | Leave a comment

Responsible JavaScript: Using ‘this’

As I’m sure we are aware by now, JavaScript is quite a remarkable language. One of the more interesting (and frustrating) aspects of the language is it’s object oriented nature. It borrows a considerable amount of its syntax from Java … Continue reading

Posted in JavaScript | 2 Comments

Responsible JavaScript: Using Factories

Wikipedia has a wonderfully dry definition of the factory pattern: The factory pattern is a creational design pattern used in software development to encapsulate the processes involved in the creation of objects. The creation of an object often requires complex … Continue reading

Posted in JavaScript | 1 Comment

Responsible JavaScript: Prototype Modification

JavaScript is a fully object oriented programming language that supports multiple inheritance models. At the heart of it all, JavaScript uses prototypal inheritance. Even the default types (String, Boolean, Number, …) are objects themselves. When you “extend” something, you don’t … Continue reading

Posted in JavaScript | 5 Comments

Responsible JavaScript: Namespaces

Continuing in my series on Responsible JavaScript, today’s discussion will be on the responsible use of namespaces. I’ve covered namespaces in JavaScript before, so I won’t go into the mechanics of how to accomplish this. Instead, I’d like to focus … Continue reading

Posted in JavaScript | Leave a comment

Responsible JavaScript: Globals

We’re always told that globals are evil and that we should never use global variables. While it certainly is true that globals offer a considerable performance hit, it is nearly impossible to avoid global variables. There are two basic types … Continue reading

Posted in JavaScript | 1 Comment

Responsible JavaScript

I’m going to kick the new year off with a 10 part series that I call “Responsible JavaScript.” Most professional JavaScript programmers are well aware of the “bad” parts of JavaScript. We’re told to avoid them at all costs and … Continue reading

Posted in JavaScript | 1 Comment

The Factory Pattern in JavaScript

We could also call this article, “JavaScript Constructors Considered Harmful.” I recall reading a post recently which describes factory methods as a best practice. I can’t tell you how thrilled this made me as I’ve been advocating this for years, … Continue reading

Posted in Code, Design Patterns, JavaScript, Uncategorized | 8 Comments