What do the curly braces do in switch statement after case in es6? What do the curly braces do in switch statement after case in es6? javascript javascript

What do the curly braces do in switch statement after case in es6?


Curly braces used in this way establish their own block scope, in which you can define local let variables or const constants:

switch (false) {    case true: {      let x = "bar";      console.log(x);      break;    }    case false: {      let x = "baz";      console.log(x);      break;    }}