12.给出执行结果并解释?
function showCase(val) { switch (val) { case ‘A’: console.log(‘Case A’); break; case ‘B’: console.log(‘Case B’); break; case undefined: console.log(‘undefied’); break; default: console.log(‘Do not know’); } }
showCase(new String(‘A’))
答案: Do not know 解析:switch 是严格比较, String 实例和 字符串不一样.