I am Hack Sparrow
Captain of the Internets.

JavaScript Array Splice – Syntax and Examples

The JavaScript splice method is a multi-purpose tool. The syntax of the Array method is as follows. Array.splice(startIndex[, endIndex, [item1[, item2, item3, ...]]]) The following examples demonstrate the way the splice method can be used. ...

Associative Arrays in JavaScript – There’s None!

That sounds strange, but it's true. JavaScript does not have associative arrays. An associative array is a kind of array which uses strings as indices, instead of numerical ones. Take a look at the code below. [code] var hero = new Array(); hero['name'] = 'batman'; hero['id'] = 'Bruce Wayne'; hero['city'] = 'Gotham City'; for (var p in hero) { console.log(p+': '+hero[p]); } console.log(hero['id']); console.log( ...

Truncating an Array in JavaScript

There are two ways of truncating an array in JavaScript. One takes advantage of the fact that the length property of the object. (mor ...