Use Array.prototype.length – 1 to compute the index of the last element of the given array and return it, otherwise return undefined.
JavaScript Booleans Explained
A boolean value is one that can either be TRUE or FALSE. If you need to know “yes” or “no” about something, then you would want to use the boolean function.
Copy text to the clipboard
Assume that we want to copy a given text to the clipboard. Here’s how.
Apply a CSS animation to an element with JavaScript
A helper function to apply a CSS animation to an element with JavaScript.
Confirm Yes or No With JavaScript
How to display a confirm dialog box using JavaScript. The confirm dialog box allows you to perform actions based on the user input.
Round a number to a specified amount of digits
Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals, to round to an integer.
JavaScript Strings Explained
In JavaScript, Strings are values made up of text and can contain letters, numbers, symbols, punctuation, and even emojis!
Calculate the size of scrollbar
The clientWidth property indicates the width without scrollbar. The offsetWidth, on the other hand, includes the scrollbar if there is.
Automatically expand a textarea as the user types
A really neat little helper function that automatically expands a textarea as the user types in.
How to Add and Subtract Time From a Date in JavaScript
How you can add time to a Date object and subtract time from a Date object in JavaScript.