showCase(new String('A'));

value为一个对象

<!DOCTYPE html>
<html>
<head>

</head>

<body>
<script>
function showCase(value){
  debugger;
  switch(value){
    case 'A':
    console.log(' Case A');
    break;
     case 'B':
    console.log(' Case B');
    break;
     case undefined:
    console.log(' undefined');
    break;
     default:
    console.log('do not know');
  }
}
showCase(new String('A'));

</script>
</body>
</html>

运行结果:

do not know

猜你喜欢

转载自blog.csdn.net/cristina_song/article/details/78057723