11 Extremely Useful JavaScript Tips

Level up your JavaScript game Image by David Monje from Unsplash 1. Converting to Boolean Using the !! Operator Sometimes, we need to check if a variable exists or if it has a valid value, to consider them as a true value. For this kind of validation, you can use the !! (double-negation operator). A simple !!variable, which will automatically …

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. …

Different ways to remove elements from an array in JavaScript

Image by Michael Dziedzic From UnSplash 1. Using the pop method Array.pop will delete the last element of an array. var array = [1,2,3,4,5]; array.pop(); array; // [1,2,3,4] array.pop(); array; // [1,2,3] 2. Using the shift method Array.shift will delete the first element of an array. var array = [1,2,3,4,5]; array.shift(); array; // [2,3,4,5] array.shift(); array; // [3,4,5] …

Design a site like this with WordPress.com
Get started