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 …

CSS Animation Events in JavaScript

Learn how to detect animation events in JavaScript Photo by Pankaj Patel on Unsplash In JavaScript we can detect animation events . The list of available animation events are animationstart → Triggered when an animation is started animationiteration → Triggered on each iteration of animation animationend → Triggered at the end of animation animationcancel → Triggered when …

Terminal Commands to Save Time and Make You More Productive

Learn essential terminal commands for every developer Photo by Mika Baumeister on Unsplash If you’re a programmer, then most of the time you will be using the terminal. This article lists some of the most important Mac/Linux terminal commands. Basic Commands clear → Clears the screen. Alternatively, we can use Cmd + K . reset → Resets …

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 …

Understanding The forEach Method for Arrays in JavaScript

Improve your iteration Photo by Mika Baumeister on Unsplash What is forEach? The forEach method executes the callback function against all element of the array. forEach method in JavaScript Syntax array.forEach(callbackFunction, [, thisArg]); // thisArg is optional arguments for callbackFunction callbackFunction(currentValue, index ,array) { //index, array is optional } The forEach method doesn’t return anything. Let’s start …

Three ways to merge arrays in JavaScript

Learn different ways to merge array in JavaScript Image by Makarios Tang 1. Using for loop We can loop through the array source array which need to be pushed , then add elements one by one function push(fromArray, toArray) { for(let i = 0, len = fromArray.length; i < len; i++) { toArray.push(fromArray[i]); } return toArray;} var array1 …

Debug Like a Lion With Chrome’s DevTools

Tips and tricks for using Chrome’s DevTools more effectively Image by Ivan Diaz You can open Chrome’s DevTools with CMD + option + J. Note: This tricks only works in the Chrome console. 1. $_ If you type $_ in the console, it will print the last evaluated expression in the console. Example: 6 + 6 …

A Quick Overview of map(), filter(), and reduce() in JavaScript

Image by Nathan Dumlao Learn how to use map, filter, and reduce in JavaScript. Higher Order Functions A higher-order function is a function that takes one or more functions as arguments or returns a function as its result. map, filter, andreduce are all higher order functions, which take a function as an argument. Map, Filter, Reduce …

Design a site like this with WordPress.com
Get started