Type assertions aka less-broken
typeof
npm install component-typeimporttypefrom'component-type';constdate=newDate();console.log(type(date));//=> 'date'type(newDate)==='date'type({})==='object'type(null)==='null'type(undefined)==='undefined'type('hey')==='string'type(true)==='boolean'type(false)==='boolean'type(12)==='number'type(type)==='function'type(/asdf/)==='regexp'type((function(){returnarguments})())==='arguments'type([])==='array'type(document.createElement('div'))==='element'type(NaN)==='nan'type(newError('Oh noes'))==='error'type(newBuffer)==='buffer'It makes no guarantees about the correctness when fed untrusted user-input.