Blog

JavaScript – Creating Classes

As many people know, JavaScript doesn’t really have classes but you can mimic some of their behavior with the prototypal setup available in JavaScript. Still, a lot of times it is just easier when you have a function that does most of the work for you. For that reason, I Read more…

By Chris West, ago
Blog

JavaScript Snippet – Undo Camel Case

Probably due to it being so late, I was looking for code to uncamelize (undo camel-casing) any string. I came across what claimed to be a solution in PHP but unfortunately did nothing but lowercased my string. Therefore I decided to write my own solution: function uncamelize(s) { return s.replace(/[A-Z]/g, Read more…

By Chris West, ago
Blog

JavaScript – Parsing A Number

If you should ever need to parse a number into an array of bits or a different base you can use the following function: var splitNumber = (function(MAX) {   for (; MAX + 1 - MAX == 1; MAX *= 2){}   return function (num, radix) {     // Validate num     num Read more…

By Chris West, ago