It's 10x-20x times faster when using vanilla JS than jQuery. However there are a few types where jQuery will give more information about the value. So here are the differences:
╔══════════════════════════════════════════════╦════════════════════════════════════════╗
║ jQuery ║ Vanilla ║
╠══════════════════════════════════════════════╬════════════════════════════════════════╣
║ jQuery.type(null) === 'null' ║ typeof null === 'object' ║
║ ║ ║
║ jQuery.type(new Boolean()) === 'boolean' ║ typeof new Boolean() === 'object' ║
║ jQuery.type(Boolean()) === 'boolean' ║ typeof Boolean() === 'object' ║
║ jQuery.type(Object(Boolean())) === 'boolean' ║ typeof Object(Boolean()) === 'object' ║
║ ║
║ Same applies to all other Constructors i.e. same result with/without new/Object() ║
║ ║
║ jQuery.type(new Number(42)) === 'number' ║ typeof new Number(42) === 'object' ║
║ jQuery.type(new String('test')) === 'string' ║ typeof new String('test') === 'object' ║
║ jQuery.type(new Date()) === 'date' ║ typeof new Date() === 'object' ║
║ jQuery.type(new Array()) === 'array' ║ typeof new Array() === 'object' ║
║ jQuery.type(new RegExp()) === 'regexp' ║ typeof new RegExp() === 'object' ║
║ jQuery.type(new Error()) === 'error' ║ typeof new Error() === 'object' ║
║ ║ ║
║ jQuery.type([]) === 'array' ║ typeof [] === 'object' ║
║ jQuery.type(/test/) === 'regexp' ║ typeof /test/ === 'object' ║
║ ║ ║
║ jQuery.type(Symbol()) === 'symbol' ║ typeof Symbol() === 'symbol' (same) ║
║ jQuery.type(Object(Symbol())) === 'symbol' ║ typeof Object(Symbol()) === 'object' ║
╚══════════════════════════════════════════════╩════════════════════════════════════════╝
However I suggest to go with dedicated methods in Lodash. E.g. _.isUndefined
, _.isString
, _.isNull
, _.isDate
, _.isError
, _.isRegExp
, _.isSymbol
, etc.
And even more powerful:
_.isNil
, _.isNaN
, _.isEmpty
, _.isArrayLike
, _.isObjectLike
, _.isPlainObject
, _.isTypedArray
, _.isSet
, _.isWeakMap
, etc.