1loc is a site packed with small JavaScript snippets that take up 1 line of code.
For example:
-
Compare Two Dates
const compare = (a, b) => a.getTime() > b.getTime();
-
Generate Number in Range
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
-
Get all siblings of an element
const siblings = ele => [].slice.call(ele.parentNode.children).filter((child) => (child !== ele));
- …