This proposal makes it easier to write functional code, you can convert
statements block into expressions producing a useful result and plugging
that back into an expression context.

This proposal is an alternative to the 'do expressions'.


Prepending `=` will automatically convert `if...else`, `switch...`, `block`
into statement that returns last inner statements value by default.

examples:

```

// the following 3 lines are equivalent

console.log(=if (expr) {a} else {b})

console.log(=if (expr) a else b)

console.log(expr ? a : b)

// print the value of statement3

console.log(={

  statement1

  statement2

  statement3

})

```


If the left hand side is an expression or operator, '=' can be omitted

```

LeftHandSideExpression = if (condition)

   statement1

[else

   statement2]

let someVal = LeftHandSideExpression * if (condition)

   statement1

[else

   statement2]

```

examples:

```

// the following 3 examples are equivalent

let x = if (expr) {a} else {b}

let x = if (expr) a else b

let x = expr ? a : b


let x = {

// statements here

console.log('print unicorn')

y // will assign y to x

}

```
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to