proposal-do-expressions
proposal-do-expressions copied to clipboard
example of do expression with switch/case
var mode = 1;
var results = do {
switch (mode) {
case 1:
'A string value'; // results is 'A string value'
break;
case 2:
5; // results is 5
break;
default:
{ a: 1 }; // results is an object
}
}
You can also find some interesting examples in the tests/comments of https://github.com/babel/babel/pull/6975