JavaScript you don't know - do expressions and eval()

The ES7 spec has a proposal for a "do expression", but the specific use cases and syntax are not widely used, so I'll just mention it here, something like this:

var a, b;

a = do {

if (true) {

b = 4 + 38;

}

};

a; // 42

In the above example, the do { .. } expression executes a block of code (containing one or more statements) and returns the result value of the last statement in it, which is then assigned to the variable a. Its purpose is to treat the statement as an expression (the statement can contain other statements), so that there is no need to encapsulate the statement as a function and then call return to return a value.

The unsafe practice of eval() (because the eval function can execute and parse all JavaScript statements, will cause a series of incalculable errors and losses):

var a, b;

a = eval( "if (true) { b = 4 + 38; }" );

a; // 42

it is also fine