Last active
July 7, 2016 07:13
-
-
Save n3dst4/d90bfb8a46598fb2b79e50bef2f59a4e to your computer and use it in GitHub Desktop.
let + switch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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