Tag Archives: javascript

Create private variables in JavaScript using closures

When you’re coming from other programming languages to JavaScript one of the things you can find frustrating is the lack of private variables. I know, coming from ActionScript to JavaScript, I was finding myself accidentally overwriting a variable and breaking … Continue reading

Posted in javascript | Tagged , | 1 Comment

Using conditionals and helpers with Handlebars.js

Last time, we looked at how we can use a JavaScript template, in our case Handlebars.js, to swap out content. But what if we have some content that isn’t going to appear in each of our content blocks? Continuing with … Continue reading

Posted in javascript | Tagged , , | Leave a comment

Use JavaScript templates to swap content

In my previous example of using a JavaScript template, I showed you how to use it to set up some static content. While that’s a good use for JS templates, you can use it to do a lot more. One … Continue reading

Posted in javascript | Tagged , , | 1 Comment

JavaScript templating will make your life a lot easier

I’ll admit it, when I first saw a tutorial explaining how to use JavaScript templates, I didn’t really see the point to it. I thought, if you really wanted to do something like that, you’d just use a server side … Continue reading

Posted in javascript | Tagged , , | 2 Comments

Build a game using the DOM – Part 4

Previously on Build a game using the DOM, in part 1 we made a block move around with the arrow keys, in part 2 we made our block shoot lasers and in part 3 we added enemies that we could … Continue reading

Posted in javascript | Tagged , , | Leave a comment

Build a game using the DOM – Part 3

In part 2, we made our ship shoot lasers and while I’m sure some people would love to play a game that consisted entirely of shooting at nothing, I think we can do a bit better. Let’s add something to … Continue reading

Posted in javascript | Tagged , , | Leave a comment

Build a game using the DOM – Part 2

In part two of building our game, we’re going to give our blue block or ship the ability to shoot lasers. But first we have to make a couple of changes in our code from part one in order to … Continue reading

Posted in javascript | Tagged , , | Leave a comment

Get the style property’s value of an element using JavaScript

Here’s a quick one. Let’s say you need to get a style property value using JavaScript, it’s actually not that complicated. But, of course, in true JavaScript fashion, the names of the methods are a bit clunky. First we have … Continue reading

Posted in javascript | Tagged | Leave a comment

Build a game using the DOM – Part 1

When I first became interested in building games using the browser and not Flash, I saw the examples people had made using HTML5’s canvas element so I started learning to build things with that. But every once in a while … Continue reading

Posted in javascript | Tagged , , | 4 Comments

Even with a name only an engineer could come up with, querySelectorAll() is pretty awesome

One of the reasons I put up tutorials and code on this site is because if something is wrong, someone will let me know, usually within an hour or two of me posting it. I’m actually really happy with how … Continue reading

Posted in javascript | Tagged , | Leave a comment