Recently I had the desire to see a comparison of the old Sing to Jehovah songbook compared to the new Sing Out Joyfully songbook. Here is the result:
Para todos que quieren ver una comparación del cancionero “Cantemos a Jehová” con el nuevo “Cantemos con Gozo a Jehová“, pueden escoger Español de las pestañas arriba.
Para todos os que querem ver uma comparação do cancioneiro “Cantemos a Jeová“, com o novo “Cante de Coração para Jeová“, você pode escolher Português das guias.
If you would like to download the above table you can choose from the following formats:
If we are dealing with smaller number then we can leverage bit-wise operators such as bit-wise negation (
~). The reason we can only use this solution for smaller numbers is because bit-wise operations can only be executed on a number in the range of
231 - 1. If the number is outside of that range it will be converted to a number within that range (eg.
There is actually a function that will convert strings into numbers called
parseInt(). We can use this function and specify the base to ensure that numbers starting with
0 will not be parsed as octals (eg.
8 in older versions of ECMAScript).
We can also use the equivalent function to
parseInt() for floats which is
parseFloat(). After that we can use
Number.prototype.toFixed() to make the number a string representation of the truncated number. Finally we can prefix this expression with a plus sign (
+) to convert the string to a number again.
We can use the newer
Math.trunc() function which should in theory just do what we want 😆 .
Below are the results of using your browser to test out each solution:
If you have looked through the results above on a modern browser (one implementing
Math.trunc()) you’ll notice that for all of our test cases, it is the only solution that works for them all. Therefore, if you are looking to convert floating-point numbers to integers or strings to integers, the most convenient and straightforward way may in fact be ES6’s new
Math.trunc() function. Let me know what you think and as always, happy coding! 😎
When working with Windows you probably have noticed that local file paths use the backslash as the path separator. Although this is the case, even on Windows, in CSS you can use the forward-slash as a path separator to reference an image. If you want to use the forward-slash though, you must escape it with another backslash. Here are two examples:
As you can see above I have three different ways to add a background image:
For the element of ID “elem1” I am specifying that the background image is found at the relative path of “relative-path\to\file.ext”. It is important to note that I am escaping the backslashes (path separators) with an additional backslash.
Just as in the previous example, if we need to reference something using an absolute path while maintaining backslashes as path separators, we need to escape all backslashes with a preceeding backslash.
For the element of ID “elem2” I am specifying that the background image is found at the relative path of “relative-path/to/file.ext”. Even though the normal path separator on Windows is a backslash you can use a forward slash.
Just as in the previous example, if we need to reference something using an absolute path we can use a forward slash as the path separator.
This may seem like a minor issue but when developing Electron apps it may come in handy. Have fun and as always, happy coding! 😎