The Single Var Pattern in JavaScript

added by JavaScript Kicks
9/30/2014 8:21:35 PM


One of the most beautiful things about JavaScript is its flexibility. The language gives developers a lot of slack by not giving us a lot of rules and conventions to deal with. A prime example: JavaScript allows us to create any type of variable, anywhere in our script (because it’s a dynamic programming language). That’s great news, but it can also be a double-edged sword if we don’t exercise a bit of caution. One popular way of working with JavaScript variables more effectively is the single var pattern.