Blog

Backup & Restore Objects in JavaScript

As I was thinking about the swap() function that jQuery uses internally, I thought some people may also find a backup() function and restore() function useful. For instance, you may get tired of worrying about using the var keyword inside of a function in order to prevent the variable from Read more…

By Chris West, ago
Blog

JavaScript – swap

A few weeks ago, while analyzing some of the CSS code for jQuery, I noticed a call to the swap() function. After looking through the definition of the function and reading the reason for using it in the documentation, I realized that this function might be pretty useful for others. Read more…

By Chris West, ago
Blog

JavaScript – Date.now()

One of the newer functions that was added as of the 5th edition of ECMA-262 is Date.now(). This function returns the number of milliseconds that have passed since January 1, 1970 at midnight GMT time (UTC). If you desire to write code that uses this newer function, in order to 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