switch statement and scopes in ES2015
问题 Consider this ES2015 module and the behavior when run in node v4.4.5. 'use strict' const outer = 1 switch ('foo') { case 'bar': const heyBar = 'HEY_BAR' break case 'baz': const heyBaz = 'HEY_BAZ' break default: const heyDefault = 'HEY_DEFAULT' } console.log( outer, // 1, makes sense, same top-level scope heyBar, // undefined. huh? I thought switch did NOT create a child scope heyBaz, // undefined. huh? I thought switch did NOT create a child scope heyDefault) // 'HEY_DEFAULT' makes sense This