Blog
JavaScript – Parsing A Number
If you should ever need to parse a number into an array of bits or a different base you can use the following function: var splitNumber = (function(MAX) { for (; MAX + 1 – MAX == 1; MAX *= Read more…
If you should ever need to parse a number into an array of bits or a different base you can use the following function: var splitNumber = (function(MAX) { for (; MAX + 1 – MAX == 1; MAX *= Read more…
Recently I had to determine when my code is running in an iframe. In order to do this many would simply use this code: Unfortunately, if you are writing code that can potentially be added to any page (even those Read more…
The other day I kind of just wanted a reason to write a Gist and embed it on my site using this method. What I came up with was a quick way to make all functions appear to be native: Read more…
One simple function that is on the roster to be released in EcmaScript 6 is String.prototype.repeat. The following can be used to define it in browsers which don’t currently have it defined natively: Here are some examples of using this Read more…
One thing that is common knowledge about JavaScript and other languages is that floating point numbers are not always stored the way you think. Also doing math with these numbers is even more iffy. One thing I recently wanted to Read more…
One thing that I always took for granted until last week was testing for negative numbers. What I mean is that I had no clue that -0 is actually different from 0. Interestingly enough when using strict equality to test Read more…
One function I didn’t think would be doable in most browsers was the Math.sign. My main worry was that on the MDN page it specifies a difference between negative zero and positive zero. After doing some research I found this Read more…
A function that is proposed to be added to EcmaScript 6 is Array.of(). This function will be used to create an array of the passed parameters. Since this function is available in some browsers but not in all, here is Read more…
Many know that JavaScript features vary from browser to browser. In the case of Firefox, there are many new features that have been proposed in EcmaScript 6. One of them is Math.hypot. This function adds up the squares of each Read more…
Now Available in YourJS At times you may need to format a string so that it is more appealing. One function that does this is String#toProperCase() because it actually capitalizes the first character of each word. Even though I already Read more…