To remove any duplicates, we can pass our array into the new Set() constructor, then convert the returned collection back into an array.
Check if all the elements in values are included in arr
Use Array.prototype.every() and Array.prototype.includes() to check if all elements of values are included in arr.
Detect Caps Lock Is On
To check if the caps lock is on, you use the getModifierState() method of the KeyboardEvent object.
Select an element or list of elements
Select an element or elements by given ID, class name, tag name, or CSS selector.
Dynamically changing the text color based on background color contrast
Get the contrasting color for any hex color.
Check if at least one element of values is included in arr
Use Array.prototype.some() and Array.prototype.includes() to check if at least one element of values is included in arr.
Check If an Element is Visible in the Viewport
In this tutorial, you’ll learn how to check if an element is visible in the viewport using JavaScript.
Press shift and enter for a new line
In some cases such as an inline editable element, or a messaging application, you would like to submit the data when user presses Enter. The only way to generate a new line is to press Shift and Enter.
Get the value of a cookie
In order to retrieve specific cookie value, we just need to get string that is after “; {name}=” and before next “;”.
Insert an HTML string after the end of the specified element
Use Element.insertAdjacentHTML() with a position of ‘afterend’ to parse htmlString and insert it after the end of el.