Helper Functions
Helper functions make complicated or repetitive tasks a bit easier, and keep your code DRY (an acronym for Don’t Repeat Yourself).
- arrayIntersect.js - Get the intersecting values between two arrays.
- buildQuery.js - Build a query string from an object of data.
- cleanHTML.js - Sanitize an HTML string to reduce the risk of XSS attacks.
- decodeHTML.js - Decode HTML entities from an encoded string.
- dedupe.js - Remove duplicate items from an array.
- deepMerge.js - Deeply merge two or more objects or arrays.
- emit.js - Emit a custom event.
- encodeHTML.js - Encode the HTML in a user-submitted string to reduce the risk of XSS attacks.
- getCookie.js - Get the value of a cookie.
- getFlagEmoji.js - Get a country’s flag emoji from its two-letter country code.
- getParam.js - Get the value of a query string from a URL.
- getParams.js - Get all URL parameters from a query string.
- getType.js - More accurately check the type of a JavaScript object.
- parseJWT.js - Decode the payload from a JSON Web Token (JWT).
- randomNumber.js - Get a random integer with a minimum and maximum value.
- randomString.js - Generate, hash, and encode cryptographically random strings.
- range.js - Create a range of numbers between two values.
- serialize.js - Serialize all form data into an object.
- shuffle.js - Randomly shuffle an array.