Rezha Julio

The Hard Coded Chemist

Number Extensions in Javascript

2018-07-17
Number benefits from several changes in ES6, providing several of new methods saving us from writing our own potentially error prone implementation. There are quite a lot of methods so here are some of the ones that are likely to have more use: Number.isFinite Determines whether a number is finite (finite means that it could be measured or have a value). Number.isFinite(Infinity); //false Number.isFinite(100); //true Number.isInteger Determines if a number is an integer or not. Continue reading

JS & Dom - Tips & Tricks #3

2017-01-13
As you might already know, your browser’s developer tools can be used to debug JavaScript by utilizing breakpoints. Breakpoints allow you to pause script execution as well as step into, out of, and over function calls. Breakpoints are added in your developer tools by means of line numbers where you indicate where you want script execution to be paused. This is fine until you start changing your code. Now a defined breakpoint may no longer be in the place you want it to be. Continue reading

JS & Dom - Tips & Tricks #2

2017-01-09
Last year, David Walsh published an article called 7 Essential JavaScript Functions where he shared some JavaScript utility/helper snippets. One of the interesting techniques used in one of the functions is where he gets the absolute URL for a page. He does this using something like the following: var getAbsoluteUrl = (function() { var a; return function(url) { if(!a) a = document.createElement('a'); a.href = url; return a.href; }; })(); // Usage getAbsoluteUrl('/something'); // https ://example. Continue reading

JS & Dom - Tips & Tricks #1

2017-01-06
There are many ways to read content from elements and nodes. Here’s another one that allows you to read and write an individual node’s value. It uses the nodeValue property of the Node interface. The nodeValue of an element will always return null, whereas text nodes, CDATA sections, comment nodes, and even attribute nodes will return the text value of the node. To demonstrate its use, I’ll use the following HTML: Continue reading