Blog

JavaScript – Add Commas To Numbers

At times, I have had to add commas to numbers in order to make them look better in different applications. Even though there isn’t a native way to do this in JavaScript, the code can be quite short, sweet and to the point: function addCommas(intNum) { return (intNum + '').replace(/(\d)(?=(\d{3})+$)/g, Read more…

By Chris West, ago
Blog

Deep Copy of Arrays

With jPaq and many other JavaScript libraries, it is very easy to do a shallow copy of an array. On the other hand, it isn’t as easy to do a deep copy of arrays. For this reason, I plan on replacing the Array.prototype.clone() function with the following: Array.prototype.clone = function(doDeepCopy) Read more…

By Chris West, ago