type names
by Maxim_Wolf
JavaScript
const show = (value, type)=>console.log(`typeof (${value}) is ${type}`);
const whatIsMyTypeName = (value)=>{
switch(typeof value){
case 'boolean':
case 'number':
case 'string': return show(value, typeof value);
default: show(value, 'выясним позднее')
}
}
whatIsMyTypeName(true);
whatIsMyTypeName(42);
whatIsMyTypeName('миру-мир!');
whatIsMyTypeName({});
whatIsMyTypeName(window);