Blog

JavaScript – Binding To A Function

ECMAScript 5 has introduced the new Function.prototype.bind() function which not only gives you the ability to natively bind a primitive or object to a function and also curry data for the function. Unfortunately, up to this point, nobody has written an implementation of this function to make it work on Read more…

By Chris West, ago
Blog

Camel Case In JavaScript

Almost a month ago, I posted about creating a camel case function in VBScript. Now I think it is time to see a simple way to implement this function in JavaScript: Believe it or not, that is all the code you will need for the following to work: You will Read more…

By Chris West, ago
Blog

JavaScript – Primitives & Objects

Purpose of the valueOf() Function Let me start off by explaining the commonly misunderstood valueOf() function. The purpose of this function is to return a primitive which represents the specified object. Why is this necessary? Let’s use the following code to illustrate why: If you were to execute this code, Read more…

By Chris West, ago
Blog

Function Overloading in JavaScript

Method overloading is one of the nice things that exists in real programming languages such as Java. Even though JavaScript starts with “Java”, there are very few similarities between the two languages. Still, due to the power of the scripting language, there is a way to overload functions. The most Read more…

By Chris West, ago
Blog

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…

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: The above code Read more…

By Chris West, ago
Blog

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. The biggest difference between this JavaScript version and the Python version is the limitation Read more…

By Chris West, ago