Blog

JavaScript Example – YourJS.toBase()

Recently I added toBase() to YourJS. The purpose of this function is to make a straight-forward way to convert numbers to a base (from 2 to 36). Of course you can easily use native JavaScript by using Number.prototype.toString(), but the beauty of this function is that it also lets us Read more…

By Chris West, ago
Blog

ES6 – Convert To Integer

There are various ways to convert a string or a floating point number to an integer in JavaScript, but not all of them may suit your needs. In this post we will examine four different ways and then we will see which is the best in all cases. Solution #1: Read more…

By Chris West, ago
Blog

EcmaScript 6 – Math.sign()

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 page which helped me realize there is a way to Read more…

By Chris West, ago
Blog

EcmaScript 6 – Array.of()

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 a block of code which when executed will define it Read more…

By Chris West, ago
Blog

EcmaScript 6 – Math.hypot()

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 argument passed and returns the square-root of that sum. In Read more…

By Chris West, ago