The “length” property of a JavaScript array is a very helpful tool, but why is array length always one “off”? Arrays in JavaScript are zero-based. This means that JavaScript starts counting from zero when it indexes an array. In other words, the index value of the first element in the array is “0” and the […]
How to Create a Name-Spaced Object to Avoid Using Global Variables in JavaScript
There are two ways to dynamically add an element to the end of a JavaScript array Sometimes you may need variables that are available to every function in your script. While it is tempting to use global variables to achieve this kind of scope, doing so can cause unpredictable results and spaghetti code. If you create […]