Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function typeChecker(_input){
- if([undefined, null, NaN].includes(_input)){
- return _input;
- }else if(_input === 'true' || _input === 'false'){
- return "Boolean";
- }else if(new RegExp(".*[a-zA-Z]+.*").test(_input) || _input === ''){
- return typeof _input;
- }else{
- return Number.isInteger(+_input) ? 'integer' : 'flaot';
- }
- }
- console.log(typeChecker(undefined));
Add Comment
Please, Sign In to add comment