Skip to content

Instantly share code, notes, and snippets.

@epreston
Created April 28, 2023 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epreston/46ea47d75124309dbe5b740615c552f3 to your computer and use it in GitHub Desktop.
Save epreston/46ea47d75124309dbe5b740615c552f3 to your computer and use it in GitHub Desktop.
javascript - type comparison functions to cleanup code
const isFn = (a) => typeof a === 'function';
const isString = (a) => typeof a === 'string';
const isNumber = (a) => typeof a === 'number';
const isArray = Array.isArray;
const isObject = (a) => a !== null && typeof a === 'object';
const isActualObject = (a) => isObject(a) && !isArray(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment