function declaration wins or variable declaration in JavaScript Hoisting

If you have a variable and a function declared with the same name, then which has a precedence over each other in the hoisting ? This video explains that. In JavaScript function and variable declarations are hoisted at the top of the execution context. You need to remember these three rules for on the same. … Continue reading function declaration wins or variable declaration in JavaScript Hoisting

Master JavaScript ‘this’ in 30 Mins

Do you know, there are four ways to calculate the value of 'this' inside a JavaScript function?  Some pointers about 'this'  Every function has it's own 'this' An arrow function does not have it's own 'this'The value of 'this' depends on, how that function is called. The value of 'this does not depend on how the function … Continue reading Master JavaScript ‘this’ in 30 Mins

JavaScript function is also a constructor?

JavaScript function is also a “constructor.” You must have heard it many times, haven’t you? Well, that is a wrong way of interpreting the JavaScript function; even though you can create an object using a function, it does not mean you can call it a constructor. Let us discuss it: There are four ways to … Continue reading JavaScript function is also a constructor?

Closures in JavaScript: Video

A JavaScript closure is a function which remembers the environment in which it was created. We can think of it as an object with one method and private variables. JavaScript closures are a special kind of object which contains the function and the local scope of the function with all the variables (environment) when the … Continue reading Closures in JavaScript: Video

Master RxJS: Part 2 – What is an observer

This is the second post in the Master RxJS series. The first post is a video tutorial that explains, why RxJS Watch it here: https://www.youtube.com/watch?v=GfuGIh-Bmxw In this post, we will discuss an observer in RxJS. An observer is an object with three call-back functions to subscribe to the notifications from an Observable. Too much technical … Continue reading Master RxJS: Part 2 – What is an observer

How to make the length of an Array read-only in JavaScript

Sometimes, you may come across a requirement that once the array is created, its length should not be changed. In this blog post, let us explore how you can achieve that. Let us say you have an array as shown below, let foo = ['1', '11']; console.log(foo.length); // 2 console.log(foo[1]); //11 As you see, the length of the array is 2, and … Continue reading How to make the length of an Array read-only in JavaScript

Link Constructors prototypes to create Inheritance in JavaScript

In JavaScript, there are multiple ways to create an object. However, among all the most popular is using a function as a constructor.   A function returns a newly created object if it is called using the new, which is also known as Constructor Invocation Pattern. You can create a function constructor like any other … Continue reading Link Constructors prototypes to create Inheritance in JavaScript