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 Snippet – getAbsPathFor()

Mission & Code Sometimes you just need a way of determining the absolute path from a specified relative path. When you are in this situation, you may use the following code: Parameters relativePath:The relative (as a string) that you would like to retrieve the corresponding absolute path for. Example To Read more…

By Chris West, ago
Blog

JavaScript – indexOf Iterator Via A Generator

Yesterday, I posted about creating String.prototype.indexOfIter() which basically returned a function which would act as an iterator function, indicating the indices of the specified substring. What I neglected to include was how to write this solution using JavaScript 1.7 in FireFox. Today, I bring to you the equivalent using a 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