Different Ways to Check if an Object is Empty in JavaScript

Learn different ways to check if an object is empty Photo by Felix Mooneeram on Unsplash 1. Using Object.keys Object.keys will return an Array, which contains the property names of the object. If the length of the array is 0, then we know that the object is empty. function isEmpty(obj) { return Object.keys(obj).length === 0;} We can …

Learn BigInt in JavaScript

Learn how to use BigInt in JavaScript to store large numbers Photo by Mika Baumeister on Unsplash BigInt is a built-in object that provides a way to store numbers larger than Number.MAX_SAFE_INTEGER. The reason for the need of BigInt is var maxIntNum = 9007199254740991; var largeNumber = maxIntNum + 2; // 9007199254740992 The expected result for the …

Understand the Superpower of Optional Chaining in JavaScript

Learn how to use upcoming JavaScript feature Optional chaining ?. → Optional Chaining operator Image from twitter by Daniel Rosenwasser (@Daniel Rosenwasser). Optional Chaining Optional chaining will eliminate the need for manually checking if a property is available in an object . With optional chaining the checking will be done internally . Example without Optional chaining. function sayHi(user) …

Understand browser readyState and how to track the interactivity of the content on your web page

Learn how to handle the browser events and the state of the document for loading, interactive, and complete Different readyState of a document The current state of the document can be accessed using readyState property of the document object. document.readyState tells us the status of the page load. There are 3 different possible states: loading — The document is …

Five Ways to Loop Through a JavaScript Array

Learn the different methods to loop through arrays in JavaScript Photo by Zan on Unsplash In JavaScript there are many ways to loop through Array. Loops which can break or skip (continue) an iteration: for while do…while for…in 2. Loops which we cannot break or skip an iteration: forEach Tip: To create an array with a …

Different ways to measure performance in JavaScript

Learn different ways to measure the time it takes to execute programs in JavaScript Image by Aron Visuals To find how much time a function, loop, or any operation takes to execute in JavaScript, we can use one of the following tools: Using console.time and console.timeEnd Using the performance.now method Using online performance testing tools 1. …

15 VS Code Extensions to Save Your Time and Make You a Better Developer

A list of useful VS Code extensions for frontend developers VS Code has a marketplace, and it contains a collection of plugins that can be installed into the text editor to make it more powerful. We can open market place by selecting Extension option in View menu or simply press shift + cmd + X . …

You Don’t Need Loops in JavaScript

Learn how to remove loops and use higher-order functions like map, reduce, and filter Image by Lysander Yuen Why Are We Replacing Loops? Using higher-order functions will make your code : More readable. Easy to understand. Easy to debug. 1. To Loop Through All Elements and Get an new modified array Using loop: var names = [“Jack”, “Jecci”, “Ram”, …

Creating a Color Generator Website in JavaScript

Learn about how to create a website which will generate unique colours Image by Paola Galimberti This is how the final result looks like In this tutorial we are only focusing on Javascript , you can just copy and paste the html and css from the above pen. The UI has Color Block → Created using JavaScript …

Basics of loops in JavaScript

Learn about Different ways to loop in JavaScript Image by Tine IvaniÄŤ What is Loop ? Consider we need to print “hi” 5 times. If we don’t have loop , what we would be doing is console.log(“hi”);console.log(“hi”);console.log(“hi”);console.log(“hi”);console.log(“hi”); But , if we know how to use loop , then we can simplify the above code to for(let i = 1; i …

Design a site like this with WordPress.com
Get started