Created
April 28, 2023 18:40
-
-
Save epreston/46ea47d75124309dbe5b740615c552f3 to your computer and use it in GitHub Desktop.
javascript - type comparison functions to cleanup code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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