Using ‘let’ as a variable name is not throwing any errors in google v8

A nice write-up of the reasoning behind this can be found in this article by Mohsen Azimi. Here’s a quick summary of it.

The following keywords are defined in the JavaScript spec as FutureReservedWord:

implements     interface   let       package    private
protected      public      static    yield

In normal mode, these can be used as variable names without errors; however, in strict mode they are treated as reserved words and will throw the following error:

SyntaxError: Cannot use the reserved word 'let' as a variable name in strict mode.

This is so that pre-ES2015 code doesn’t break – if someone had named lots of their variables let in a legacy app, they probably wouldn’t be happy if the JS spec suddenly broke everything.

Leave a Comment