ngClass Use Case Examples

ngClass is a very powerful built-in Angular directive for dynamically changing CSS classes on HTML elements. It does this by allowing us to bind scope values as class names. We can then use the state of our application (what variables are currently assigned to) to assign classes to divs, h2s, you name it.  Summed up, […]

javascript logo

JavaScript Events 101

A lot of things happen on webpages. People scroll, click, and move their mouses. Form inputs get entered and typed into. Pages load or get resized. These actions (and many others) are aptly called ‘events’ in web development. And responding to these events is a large part of what makes web applications interactive. Users do […]


Getting to know the ReactJS ecosystem – React and React Native

For new web developers, just learning javascript can be hard enough, let alone trying to understand the dozens of popular libraries, frameworks, services, architectures, preprocessors, bundlers, and other technologies in wide use today. It can all make web development seem esoteric and inaccessible. If you feel this way, you are not alone! I’m here to […]


How to Add/Remove CSS classes using JavaScript

This post will demonstrate two approaches for manipulating the classes of an HTML element. The first uses the plain javascript property classList and the second uses jQuery, a popular javascript library. To begin, consider the following document:

The document has one button with an onclick event to toggle the color of the button. The […]


How to replace all spaces in JavaScript?

In computer programming, “find and replace” is a pretty common task. Any programmer that’s interested in working with textual data should have at least a rudimentary idea of how to write a basic find and replace algorithm. In the JavaScript programming language, find and replace functions are not hard to implement. In the following examples, […]


How to Check If a Key Exists in a JavaScript Object?

JavaScript objects are comprised of properties. Properties in JavaScript are defined as pairs of keys and values. Keys can be generally thought of as the names of the values stored within JavaScript objects. There are a few different ways in which to check if a specific key exists within a certain object. And depending on […]


Working with the Date Object in JavaScript

Getting the current date in JavaScript is a piece of cake. The language features a convenient Date object that’s preloaded with all sorts of methods for retrieving temporal values. The syntax is simple enough and the names of the methods, for the most part, are pretty intuitive. In the following examples, I’ll show you how […]


Working With Promises in AngularJS Services

Let’s talk about working with promises in AngularJS. To start, $q is a great implementation of promises, allowing you work with deferred objects and be more efficient with Ajax calls. $q api has few useful methods, first one is to create new deferred object using $q.defer(), so this object could be resolve in the future […]


Quick and Dirty JavaScript Closures Guide

Understanding closures is crucial to being a successful javascript developer. The purpose of this post is to provide an introduction to closures, as well as some examples of what you can do with them. This post assumes you have an understanding of how variable scope works in javascript. Put simply, a closure is a nested […]


Ways to Loop Over an Array in JavaScript

Ways to loop over an array in JavaScript? There are a multitude of ways to loop over an array in JavaScript; some common, some less so. Probably the most familiar ways to loop over an array in JavaScript are the for loop and the while loop; for/in loops will work as well, but are traditionally […]