function chekFn(a){ var myas = typeof a; switch(myas){ case 'undefined': console.log('undefined'); break; case 'null': console.log(null); break; case 'number': console.log('num'); break; case 'string': console.log('string'); break; case 'boolean': console.log('boolean'); break; case 'object': console.log('object') break; } } chekFn('dfas'); //string chekFn(); // undefined chekFn(true); //boolean chekFn(null); //object chekFn(undefined); //undefined chekFn([]); //object