I needed to sort an array of objects in JavaScript recently and was quite frankly amazed by 2 things: I’d never done it before in 7+ years of JavaScript It’s really rather easy! JavaScript has Array.sort that will order an array’s contents in ascending alphabetical order. So: var testArray = ['c', 'a', 'b']; testArray.sort(); //sorts [...]
This is one of those really annoying pieces of syntax that I can never remember and that I always have to look up so I figured that other people would surely have the same issue :) Anyway, see below for how to write CDATA comments in your JavaScript to make it XHTML compliant.
On a recent project I was asked to add some client side functionality to an input field, so that people clicking in the input box would have the contents auto-selected. Not a problem, a fairly easy piece of work, especially with jQuery . This evolved into additional functionality to improve the usability of the input [...]