Archive for the ‘JavaScript’ Category

JavaScript and Web Performance books you need to read

Sunday, June 6th, 2010

This is a list of some JavaScript based web development books I own and which I can fully recommend to any aspiring JavaScript ninjas. I describe below what I thought of each book and why I like them enough to recommend them…

(more…)

JavaScript’s Regular Expression exec/lastIndex bug?

Sunday, June 6th, 2010

There is a slight bug in how *certain* browsers handle JavaScript’s Regular Expression exec() method, and the two legends of Regular Expressions…

  1. Jan Goyvaerts (www.regexguru.com)
  2. Steven Levithan (blog.stevenlevithan.com)

…(both co-authors of the Regular Expressions Cookbook) seem to be in disagreement with each other as to how Internet Explorer implements this.

(more…)

Regular Expression to open external links in popup window

Tuesday, June 1st, 2010

This is a quick post to show you how to open up external website links within a pop-up window (without adding extra non semantic mark-up to your HTML code). In the past I’ve heard a lot of people talk about adding either custom attributes or using existing attributes such as rel as a hook for your JavaScript code to find links that should open in a pop-up window. I disagree, and suggest using Regular Expressions (regexes) along with some procedural code to help figure this out for you (it will save you the time and hassle of adding this extra mark-up yourself).

(more…)

Regular Expression Header Text Replacement

Thursday, May 27th, 2010

This is a post about some of my findings whilst trying to use Regular Expressions (Regex) to solve some problematic string issues. Along the way I learned something new about JavaScript’s text replacement methods that I didn’t know before and although it was very interesting to finally figure out, I was still slightly annoyed that it didn’t feature more prominently in more leading JavaScript books on the relevant sections of Regexes and text replacement using Regexes.

(more…)

Implementing Interfaces in JavaScript

Sunday, February 14th, 2010

In Object-Oriented languages an interface defines a set of methods which a Class must include in order to implement the interface (otherwise, if the Class is missing the required methods, the code will fail and the interface will throw an error).

Interfaces are useful for making sure developers use the correct implementation of an API.

In JavaScript there are no true ‘classic’ Object-Oriented features, but through clever usage of the language you can emulate an Interface for use with a JavaScript API.

(more…)