Quantcast
Channel: Zeroed & Noughted » JavaScript
Browsing latest articles
Browse All 10 View Live

Bookmarklet to de-cache CSS and images – Version 2

You may recall, in this previous post I showed you how to use a bookmarklet (typically a small piece of JavaScript you can save as a bookmark and run against a page) to get the latest versions of CSS...

View Article



Centre div in window, in iFrame, from iFrame, without an iFrame ID

Update: This code has been replaced. Centring a div is not so hard. Centring a div on a window regardless of the windows scroll position is a little harder. Centring a div in the viewport in an iFrame...

View Article

Six Ways to Iterate Through an Array (or Chrome’s V8 is a Monster)

There are actually all kinds of ways to iterate through an array in JavaScript. Here, I will concentrate on six of them, describe their advantages, and do performance testing to actually prove which of...

View Article

Checking if an implied object is empty

An implied JavaScript object (e.g. var o = {};) will always be a truthy value. Since we have no index or length, there is no graceful way to check whether or not these variables have been populated....

View Article

Image may be NSFW.
Clik here to view.

Using previously highlighted text in TextMate snippets

In a previous (and very verbose) post on TextMate snippets, I showed a snippet to easily and simply use a tab trigger to insert a try... catch statement. If you missed it feel free to catch up here....

View Article


Checking for Duplicates in a JavaScript Array

JavaScript has an in operator, that allows us to look through an object to see if we can find a property. If we create an object containing particular items in an array, we can then look through those...

View Article

Centre div in window no matter what – Version 2

In a previous post I showed you how to center a div on screen regardless of if it was inside an iframe or not. This is the second version, which should work regardless of if the div is in the top level...

View Article

Regular Expression to match UK residential telephone numbers

A regular expression to match UK residential telephone numbers. It understands the difference between 02 and 01 numbers. It will accept all common formats and internationally formatted numbers....

View Article


Destructuring assignments in JavaScript 1.7

Destructuring assignments are great for time saving methods of assigning values to variables. They make for shorter code, and shorter code is less error prone. A destructuring assignment essentially...

View Article


Defensive AJAX and AJAX retries in jQuery

A lot of code that I have seen over the years always assumes success, particularly with AJAX calls. This creates code that is fragile, and entirely dependant on the result of external (to the client)...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images