Guest User

Untitled

a guest
May 27th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function typeChecker(_input){
  2. if([undefined, null, NaN].includes(_input)){
  3. return _input;
  4. }else if(_input === 'true' || _input === 'false'){
  5. return "Boolean";
  6. }else if(new RegExp(".*[a-zA-Z]+.*").test(_input) || _input === ''){
  7. return typeof _input;
  8. }else{
  9. return Number.isInteger(+_input) ? 'integer' : 'flaot';
  10. }
  11. }
  12.  
  13. console.log(typeChecker(undefined));
Add Comment
Please, Sign In to add comment