Use typeof to check if a value is classified as a string primitive.
Detect Internet Explorer browser
Check if the current browser is Internet Explorer (IE).
Check if the given number falls within the given range
Use arithmetic comparison to check if the given number is in the specified range.
Get all siblings of an element
A simplified approach using some ES6 methods.
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 Siblings of an Element
This snippet gets the next sibling and previous sibling of an element, using the element.nextSibling and element. previousSibling properties.
Get size of the selected file
This snippet can be used to validate a file’s size and display it, for instance when a file is being submitted for upload.
Resize an iframe to fit its content
This snippet gets the height of an iframe’s content and then sets the height of the iframe to match.
Xmas Tree Generator
This script makes a random sized Christmas tree with random lights.