JavaScript
Private Members In CoffeeScript
I’m a big fan of CoffeeScript. I find it to be more expressive and less clunky than regular JavaScript, plus it makes it easier to extend objects and emphasises lambdas. However, CoffeeScript partially obscures the native closures in JavaScript and as a result makes it very difficult to use private variables and methods.
Classes, Inheritance And Mixins In JavaScript
JavaScript doesn’t have native support for classes. Functions can be used to simulate classes (somewhat), but in general JavaScript is a class-less language. Everything is an object. This makes inheritance particularly strange, since objects inherit from objects, not classes from classes as in languages like Ruby or Java.
Internal Classes In CoffeeScript
CoffeeScript provides us with a very nice syntax for creating classes.
Using Custom Directives in AngularJS
One of the areas I found the most confusing when starting out with Angular was directives. However, once I got comfortable with directives I found it to be true what most articles on directives were saying – they are really powerful and can really clean up your code.
Prevent a User Navigating Away from a Page with Unsaved Changes
On my current project we have the problem where users will often navigate away from a page without saving their changes. The users of our application are often unfamiliar with websites and therefore simply navigate away without hitting update (as you would if you’re only familiar with desktop applications).
Integrating EJS Templates into Rails
I’ve been on few projects where we need to have client-side view templates. This would mostly involve making an AJAX request to the server, getting back some JSON data at which point we need to convert this into HTML. EJS is one of a number of solutions to this problem.
AngularJS Pain Points
I’ve been using AngularJS for almost 3 months. I had heard quite a lot about Angular before this time – many people were talking about it being the ‘next big thing’ and how it could become the defacto JavaScript framework for client-side development.
Check if a variable is defined in CoffeeScript
In JavaScript it’s pretty common to check if a variable has been created. You would usually perform the check with the following code:
Debugging CoffeeScript Line-by-Line
One of the main arguments against using CoffeeScript is that of debugging. CoffeeScript is compiled down to JavaScript before being sent to the browser which means we can only debug the compiled JavaScript version of our code, not the original CoffeeScript. Until now, that is.
Custom Sorting in AngularJS
Today I had to implement custom sorting in AngularJS. As with most things in Angular it’s very simple once you figure out how.
10 CoffeeScript Features You Might Not Know
This week I’ve spent some time researching different CoffeeScript resources to be used for training at a client. In the process I’ve discover a few CoffeeScript features that I didn’t know about or are not that well known.
Resources for Learning CoffeeScript
CoffeeScript is a little language that compiles down to JavaScript. I’m a big fan of JavaScript, but it’s definitely a very quirkly language. CoffeeScript eliminates some of those quirks and brings JavaScript’s syntax more in line with languages like Ruby and Python.
Using ngResource with AngularJS
In my first post on AngularJS I created a simple Todo application with a Rails/Mongo RESTful server. In this application I was doing all my ajax calls manually (which is really easy in Angular), which meant most of my controller methods looked like this:
Using Spine.js mobile
For the past 3 weeks I’ve been working on a mobile website for a hybrid iPhone app. We were already using Spine.js – as I mentioned in a previous post – and therefore Spine.js mobile was an attractive choice for building the mobile part of our website.
Shared Examples with Jasmine
On my current project we’re doing quite a bit of JavaScript development using CoffeeScript and the Spine.js framework. Since we practice TDD we’re using Jasmine to drive all our CoffeeScript code and I’ve found it to be a great little framework.
Six months with Spine.js
I have spent the last six months on a project where we are using Spine.js as one of the main technologies. Spine is a JavaScript library that allows you to build client-side-heavy applications with the MVC pattern using CoffeeScript.
Method Resolution in Ruby
While reading the Ruby Pickaxe book I realized that while JavaScript and Ruby are both dynamic languages, they handle method resolution in very different ways. I often use JavaScript as a reference since it’s the dynamic language I’m most familiar with.
JavaScript (or any other) as a First Language
A few weeks ago John Resig announced that Khan Academy will most likely be using JavaScript as the language of choice in Computer Science – prompting the discussion on the viability of using JavaScript as a first language.
Better JavaScript–Iterating Arrays
If you do JavaScript on a regular basis you probably end up iterating over arrays fairly often. And if you’re anything like me you’re going to end up missing the foreach looping construct in C#.
Better JavaScript–What is this?
JavaScript has quite a few ways of using the this keyword, but it’s not really that difficult to know what this means in the different contexts. Let’s take a look at the different meanings of this.
Better JavaScript-User Defined Objects
In my last post I had a look at how we declare namespaces in JavaScript. In that example I simply declared a function which was then accessible anywhere by simply referencing the correct namespace. Today I’m going to take a look at creating custom JavaScript objects using the same kind of namespace syntax.
Better JavaScript–Namespaces
I have recently had the opportunity to do some JavaScript-heavy programming which has allowed me take stock of my understanding of the different structures in this language. Today I’m going to look at one of the most straightforward challenges in JavaScript – declaring namespaces.
3D Tic-Tac-Toe with HTML5
I recently helped to organize a programming contest where you were required to write a Tic-tac-toe game using only HTML, CSS and JavaScript. You then had to host your solution on jsFiddle.
Ajax improvements in MVC 3
This post is part of the series I’m doing on the newly released ASP.NET MVC 3.
Authentication with OpenId–Part 2
I my last post I created a very simple example of how to authenticate users with OpenId. In that example the user needed to enter the full URL to their OpenId provider. Today I’m going to modify that example to make the authentication process a little easier on the user. To give you an idea of what I’m going on about, take a look at the login form for StackOverflow.
Why FIFA.com crashed
If you’re soccer fan like me (the World Cup is only 2 weeks away!) you probably encountered considerable frustration in the past week. This is due to FIFA ticketing system. FIFA allow fans to buy tickets through the FIFA.com website (which generally works pretty well), but in the past few weeks there have been a number of outages leading to some seriously annoyed customers. This culminated on Friday – FIFA had announced that 150 000 extra tickets would go on sale by 9 AM, but their website simply couldn’t handle the extra load and 24 hours later the problem still hadn’t been resolved.
Debugging JavaScript errors
I have noticed that quite a few developers are unaware of one of the simplest methods of finding JavaScript errors in your page. JavaScript exposes an event handler that fires whenever a JavaScript error occurs in a page. Using it we can suppress all JavaScript errors on the page or display an error dialog.