Created
April 21, 2020 07:59
-
-
Save glebcha/16c51a5a85f0e754b626f46030ab650c to your computer and use it in GitHub Desktop.
Check common js types
This file contains hidden or 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 modifier = type => item => Object.prototype.toString.call(item) === `[object ${type}]`; | |
const checkTypes = ['String', 'Function', 'Number', 'Boolean', 'Object', 'Symbol']; | |
const is = checkTypes.reduce((checkers, type) => ({ ...checkers, [type]: modifier(type) }), {}); | |
is.Function(null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment