Tag javascript

Observer Pattern

According to the GoF book, Design Patterns: Elements of Reusable Object-Oriented Software, the definition of Observer Pattern is: “One or more observers are interested in the state of a subject and register their interest with the subject by attaching themselves. When something changes in our subject that the observer may be interested in, a notify

Read More


Why do you bind?

Have you ever run into a problem where you have added an event listener using bind, but the event handler continues to execute even though you have removed the listener? If yes, read on. A few months ago, when I was working on one of the React components, I added an event listener to the

Read More


Undefined Vs Null

In JavaScript, both undefined and null come under primitive data types. But they are not as simple as a string, number, and boolean. A variable is said to be undefined when it has been declared (for future use) but has no value assigned to it. For example, Line 2 prints undefined in double quotes, i.e.

Read More


Data Types in Javascript

JavaScript is not strict when it comes to data types and use of variables if we are writing codes without using ‘use strict’. None of the code example in this post has been written with ‘use strict’ option. As a result, we can use a variable (without declaring it) and the JavaScript engine won’t have

Read More