What are getters and setters in JavaScript

In JavaScript, you may have heard of getters and setters. Let’s take a look at what these things are.First, a setter is used to set the value of a property. A setter gets called each time the value of the property is changed. In other words, it executes a function for each time a property … Continue reading What are getters and setters in JavaScript

Advertisements

Simplifying function hoisting in JavaScript

To understand function hoisting, let us start by considering the code listed below:In any other programming language, the output here would be a reference error. However, in JavaScript you will get undefined as the output. Why? Because JavaScript hoists variables at the top of the execution context. An execution context could be the function in … Continue reading Simplifying function hoisting in JavaScript

What is the arguments object in a JavaScript function?

A JavaScript function has array-like objects called arguments which correspond to the arguments passed to the function. All arguments passed to a JavaScript function can be referred using the arguments object.  Now as we get started, let’s consider the code listed here:In the above function, num1 and num2 are two arguments.  You can refer to … Continue reading What is the arguments object in a JavaScript function?