To get the width and height of an element, you use the offsetWidth and offsetHeight properties of the element.
Detect the dark mode
Modern operating systems allow users to choose the appearance they would like to see in all applications. The option can be detected by looking at the prefers-color-scheme media query.
Check if a date is after another date
Use the greater than operator (>) to check if the first date comes after the second one.
Get all siblings of an element
A simplified approach using some ES6 methods.
Get the text content of an element
Returns the raw text content of the ele element and its children.
Get the Width and Height of the Window
How to get the width and height of the window in px.
Check if a date is before another date
Use the less than operator (<) to check if the first date comes before the second one.
Check if two arrays or objects are equal
A robust way to compare two arrays (or objects) and check if they’re equal to each other.
Prevent the default action of an event
Use the preventDefault() method. This method works with inline attribute.
Get and Set Scroll Position of an Element
To set or get the scroll position of an element, you use the properties scrollTop and scrollLeft of the element.