Code Notes

JavaScript

Tips and tricks I learned throughout the years.

JavaScript looks familiar to many engineers, but behaves differently in all the places that matter. Here I share practical lessons that help whether you're just getting started or already shipping in production.

JavaScript tips - Page 2

Magical JavaScript Live Collection

JavaScript live collection is a subject that is rarely talked about. Earlier I had written about a caveat when using them. It did help people but one of the problem is that most didn't understand what was happening and t…

Read article

Creating a class in JavaScript

It comes to a surprise that JavaScript, the most popular language on the web, has the most unconventional method for creating a class. In most object oriented programming languages, classes follow a common syntax. Here i…

Read article

When to use Object.hasOwnProperty

In JavaScript, everything is an object. This is amazing because you never have to ask yourself if something is an object. The answer is always Yes. Let's look at a few examples: // a number is an object var num = 32; num…

Read article

Loading jQuery asynchronously

The recommended way to load jQuery is with a script tag. You place it on the bottom of your page and make sure every script that depends on it are loaded after. However, what happens when you want to load all your script…

Read article

How to get an element position on the page

This used to be a painful thing to find on the page. Well it wasn't but almost everyone suggested you use a hacky way to find the correct position of an element. The method was so popular that it wasn't even considered a…

Read article

Ajax without jQuery

It took me a long time to implement jQuery into my everyday workflow but now I am so used to it that I rely on it entirely for some tasks. The more I use, the more I forget how to manually make stuff. How do you make an …

Read article

Please don't detect the browser

Feature detection is a term everyone in the web development world has heard of. Yet, we still find code that tries to detect which browser the user is running to perform a task. This needs to stop! Technology has evolved…

Read article

Dealing with Live HTML Collections

To select elements from the DOM, we use browsers APIs like getElementsBy*. To make our lives easier, the result of these methods are Live. What this means is that when the DOM updates, I don't need to fetch it again from…

Read article

Previous Page 2 Next