Skip to content

Instantly share code, notes, and snippets.

@n3dst4
Last active July 7, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n3dst4/d90bfb8a46598fb2b79e50bef2f59a4e to your computer and use it in GitHub Desktop.
Save n3dst4/d90bfb8a46598fb2b79e50bef2f59a4e to your computer and use it in GitHub Desktop.
let + switch
// What is the console output of this code?
function switchFoo (foo) {
switch (foo) {
case 1:
foo = 5
console.log(foo)
case 2: {
console.log(foo)
break
}
case 3: {
let foo = 6
console.log(foo)
}
case 4: {
console.log(foo)
break
}
}
}
switchFoo(1)
switchFoo(2)
switchFoo(3)
switchFoo(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment