## JavaScript – Cube Root & Beyond

Learn how to take the cube root, 4th root, 5th root, etc. of numbers in JavaScript.

## Convert Anything To A Number

There are many times in JavaScript when you need to scrub the input and give output of a specific type. Today, I will cover how you can convert anything into a number. The function to do so is as follows: // Converts any object into a number. function parseNumber(obj) { Read more…

## Math In the Address Bar

Did you know that you can do math problems in the address bar of your browser? Regardless of what browser your using, you can use its address bar to find the answer to an arithmetic problem. For instance, let’s say that you are using Internet Explorer and all of a Read more…

## Private Variables In JavaScript

Often times, many people have made claims that it is not possible to make variables private in JavaScript. I am here to tell you that those people are wrong. There are many implementations from JavaScript guru’s such as Douglas Crockford explaining how to do this. Although these implementations will get Read more…

## 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…

## Power Set

As I was beefing up my past implementation of cartesianProductOf(), I decided to look into set theory a little bit more. After looking through some Wikipedia pages, I found another process that may be of interest to JavaScript programmers that have to deal with sets: a JavaScript implementation of finding Read more…

## Cartesian Product of Multiple Arrays

A few weeks ago, I came across a question about finding the cartesian product of two or more arrays in JavaScript. For anybody who is looking to do so, I posted the following code on stackoverflow: function cartesianProductOf() { return Array.prototype.reduce.call(arguments, function(a, b) { var ret = []; a.forEach(function(a) { Read more…

## Currying Up More Examples

A few weeks ago, I wrote an example page on jPaq.org for using the curry function to easily add prototypal functions to the String object. As I was playing around with jPaq, I thought of a few more examples: // Returns an array of all of the characters in the Read more…

## String.prototype.expandTabs()

I personally love both JavaScript and Python. For this reason, from time to time I like to port functions that are available in Python, over to JavaScript. The following is a port of the expandTabs function. String.prototype.expandTabs = function(tabSize) { tabSize = Math.min(Math.max(parseInt(+tabSize || 8), 1), 32); return this.replace(/^.*\t.*\$/gm, function(line) Read more…

## String.protototype.toCharCodes()

One of the functions that didn’t make the cut for jPaq is String.prototype.toCharCodes().  The reason is I don’t feel that it is a function that many people are looking for.  Still, if you are looking for a good implementation for it, you can use this: String.prototype.toCharCodes = function() { for(var Read more…