I think most people would prefer not having the full class so I set it to false
Oh I gotcha, I first didn't understand what you meant to do with a non provided variable but it's actually undefined when not passed and therefore false. All good.
Looks good. Very useful! For testing purposes I renamed the function to showType() but if someone wants to see the differences here you go:
constmain=()=>{consttests=[['an','array'],`the result is ${1+2}`,1n,newDate(),newError('an error'),function(){},function*(){},/regex/gi,Symbol(),'not a number'/2,document.querySelector('body'),1/0,null,];for(const[i,test]oftests.entries()){console.log(test);console.log('showType: '+showType(test));console.log('showType fullClass: '+showType(test,true));console.log('typeof: '+typeoftest);i<tests.length-1?console.log('========================'):null}};
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks!
Nice catch on the NaN. I think
Object.is
would fix it, right?I think most people would prefer not having the full class so I set it to false
Oh I gotcha, I first didn't understand what you meant to do with a non provided variable but it's actually undefined when not passed and therefore false. All good.
Looks good. Very useful! For testing purposes I renamed the function to
showType()
but if someone wants to see the differences here you go: