Updated on September 8, 2016
As the web transitions to ES6, developers will need to break their habit of using var. The toolbox now contains const and let, which should replace var in all instances.
Now that that’s out there, the real question now is which to use when? TL,DR: always use const, unless it’s a native value (number, string, null, etc.) that could change, then use let.
The Case Against var
Almost Always: const
Some have said that it obscures the code’s intent and can be confusing when compared to other languages. This is understandable but a counter could be var is just as confusing to new developers due to scope.
This one is the exception to the rule. There’s always values that will change, and when a primitive does, use let. Then why is it better than var since let sounds like the same thing?
The answer is because of block scope. var has function scope, whereas let has block scope or within curly braces. As I mentioned earlier, this cuts confusion and keeps the code from stepping on itself. This emulates the behavior of other popular languages.
Stop Using var
Due to some browsers being slow to put ES6 features in place, dropping the var habit may take some time. Node has these baked in, so go ahead and start implementing them there. This will not only make the code future-proof, but make it easier to understand. So my advice, don’t use var anymore.
Updated on August 23, 2016
ES6 is here and the recent versions of Node (> 4.0) have integrated some new features. There’s no need for using a transpiler since it’s built into the language now, horray! These features don’t require a rewrite of code, just keep these in mind when starting the next Node app. Here’s a breakdown of a few Node ES6 features that are available today. Read More
Updated on June 28, 2016
A while ago I wrote an article about using JSHint using Gulp. In the time since that article, I’ve made the switch to ESLint. Which for my money, does a better job of not only checking for syntax errors, but enforcing a style guide. So I figured I would write a quick complementary guide for ESLint using Gulp.
If you’re not familiar with ESLint, it’s JSHint on steroids. It’s extremely flexible, provides the most rules out of any linter, and has support for JSX. Which with the recent growth of React, makes it the defacto tool for linting React files. If your still using JSHint, definitely give ESLint a look.
As in the other article, I’m going to assume you have a knowledge of Node and NPM, as well as a little working knowledge of how Gulp works. If you don’t, definitely check out my getting started in Node series and the JSHint using Gulp article linked above. Read More
Updated on April 25, 2016
I know for the past two months I’ve been somewhat neglecting my blog (plus my newsletter, but more on that later) but I figured it was time to give a life update. It was not without reason though. I’ve recently had a big change in my life in that, I’ve left the government life behind and traded it for joining Pure Chat, an early stage startup.
If anyone has known me, you’ll know that joining a startup has been somewhat of a dream of mine (that or start my own :P). The whole thing came together pretty quickly but I’m more than excited to get in on the ground floor of an awesome team. Read More
Posted on February 4, 2016
- Be Tiny
- Allow bookmarking of sub views
- Assume jQuery as the only available library
I poked around the interwebs, and used Microjs to see if one of them fits what I’m looking for. None quite did, so I did what any other developer usually does, wrote one myself!
Another point to make is that, all the HTML required was already loaded into the page. I didn’t need any AJAX at all. I wanted it to be a completely client-side solution. Read More