execjs icon indicating copy to clipboard operation
execjs copied to clipboard

ExecJS::ProgramError: Unexpected token: name (key)

Open jeremylynch opened this issue 9 years ago • 0 comments

The following code is raising this error: ExecJS::ProgramError: Unexpected token: name (key)

var key = 'dummy',
    plugin = {};

plugin.variables = {
    [key + '1']: "1",
    [key + 'Ctrl-2']: "2",
};

However this code does not:

var key = 'dummy',
    plugin = { variables: {} };

plugin.variables[key + '1'] = "1";
plugin.variables[key + 'Ctrl-2'] = "2",

I understand that the former is ES6 compatible and the latter is ES5 compatible. Is this the reason I am getting the error?

jeremylynch avatar Apr 11 '16 12:04 jeremylynch