Definition An IIFE is a coding pattern called an Immediately Invoked Function Expression which is a way to execute a JavaScript function immediately after it is created. Also pronounced as “iffy.” Let’s look at the traditional and more widely used syntax used to declare an IIFE. The ES6 way: (() => { /* statements */ })() The ES5 way: (function()… Continue reading Understanding the coding pattern called (IIFE)
Tag: javascript
Currying in JavaScript
In this growing world of JavaScript, where almost everything can be achieved through functions. We must be aware of the techniques such as closures, pure functions, recursion, etc. which help in making our programming lives easier. Thus in this journey of learning functional programming through JavaScript, I will be walking you through one such technique… Continue reading Currying in JavaScript
Nullish Coalescing (??) Operator
WHAT? It is a new Logical operator meant for short-circuiting to handle default values. It returns it’s right-hand side operand when its left-hand side operand is null or undefined, otherwise returns its left-hand side operand. WHY? To assign some default values to the variable if it is null or undefined we use nullish coalescing. On the other hand, if we use logical OR(||)… Continue reading Nullish Coalescing (??) Operator
Efficient Code with JS functions
The craft of programming is the factoring of a set of requirements into a set of functions and data structures. Functions are one of the key components in programming. They are defined to perform a specific task and to perform it again and again whenever called. Simple and straightforward, right? The best thing about JavaScript is its implementation… Continue reading Efficient Code with JS functions
Shallow or Deep Copy?
Before going forward, let us understand Objects and references in JavaScript. What is an Object?? Object is a container of properties associated as key and value pairs. The values in an Object can be functions that are commonly referred to as methods. Object is created only once in JavaScript, and we can refer Object by… Continue reading Shallow or Deep Copy?
Inheritance in JS — Prototype and class Inheritance
Unlike all other object-oriented programming languages, JavaScript chose prototypes for its way of handling inheritance, but with the release of ES2015, classes were introduced to the language’s syntax. Let me put light on thought: Classes are just syntactic sugar, JavaScript remains prototype based. They are not a new object-oriented inheritance model. Let’s understand the Prototype first… Continue reading Inheritance in JS — Prototype and class Inheritance
What is difference between unescape() and escape() functions in JavaScript?
JavaScript provides two functions for dealing with encoded strings: escape() and unescape(). The escape() function is used to encode a string, making it safe for use in a URL. The unescape() function is used to decode an encoded string. The differences The main difference between the two functions is that escape() encodes characters that are not ASCII, while unescape() only decodes those characters. This means that… Continue reading What is difference between unescape() and escape() functions in JavaScript?
Map vs FlatMap: Next.js
Map: Definition: The map method is used to iterate over an array and execute a provided function on each element of the array, creating a new array with the results of calling the function for each element. Practical Use: Transforming data: map is commonly used to transform arrays of data into a new format. Rendering… Continue reading Map vs FlatMap: Next.js
Mastering JavaScript: Multiple Ways to Generate a Two-Dimensional Array
Can you generate a two-dimensional array using JavaScript? This question might seem simple. Just as there are various methods to achieve the same goal, there are also various methods to generate a two-dimensional array. Today, let’s explore the answers behind this question and uncover the secrets of generating two-dimensional arrays. Knowing different methods not only… Continue reading Mastering JavaScript: Multiple Ways to Generate a Two-Dimensional Array
Implementing JavaScript Concepts from Scratch
In this article, we explore the foundational building blocks of JavaScript by crafting several key components from the ground up. As we delve into these concepts, we will apply a range of techniques, from basic to sophisticated, making this exploration valuable for both newcomers to the JavaScript world and professionals. TOC memoize() Array.map() Array.filter() Array.reduce()… Continue reading Implementing JavaScript Concepts from Scratch