Blog

POW – Unnamed Function #1

This Problem of the Week involves determining the identity of a well-known mathematical function by examining the algorithm used on the input number to produce the output.  The function will only accept integers that are greater than or equal to zero. The following is the mathematical definition of the function: Function Definition Condition Read more…

By Chris West, ago
Blog

JavaScript Snippet – RegExp.prototype.clone()

There have been many times when I needed to simply modify the flags (options) for a regular expression in JavaScript. Unfortunately, the global, ignoreCase, multiline, and sticky (for FireFox) flags are immutable. In addition, when creating a new regular expression from an old one, you can’t supply a regular expression Read more…

By Chris West, ago
Blog

JavaScript – indexOf Iterator

One of the cool things about JavaScript 1.7 is the fact that it supports generator functions. Unfortunately, not all browsers support generator functions yet. Therefore, when creating iterators we can look to an interesting alternative: closures. For example, if our goal was to make a String prototype function which would Read more…

By Chris West, ago
Blog

Quick JavaScript Encryption Method

Recently, I have been interested in creating a quick one-way encryption method. After playing around with a lot of different variations, I settled on the following: One nice thing about this function is the fact that you can restrict the encrypted message to a certain length. Another interesting thing is Read more…

By Chris West, ago