Let and Const in Immediate Window


It seems like let and const are unsupported in Cloud 9’s immediate window yet other ES6 things work. Is this correct and is there a reason for this? Or am I doing something wrong?


Unfortunately es6 have specified let const and import in a manner hostile to usability in the repl.

When using eval bindings created by these are limited to the scope of the eval call and are not present in the next call.
When using script bindings are unchangeable and it is not possible to run the same line twice, and that breaks repl history, (Also in this case it is not possible to get the completion value by means available to normal js, so we can’t use it either way).

The only thing that we can do is automatically replacing let and const with var which behaves in a sane manner, but this will be confusing as well, since code that works in the repl, often won’t work outside of it.


Thanks for that explanation! That’s good to know.