language design - is javascript's `return` really a *keyword*? -


this snip ran without complain on both nodejs , browser:

this.return = function ( x ) {      return x  };  console.log ( this.return(1) ); 

i expecting fail hard syntax error.

i meant, can understand why this['return'] works.. though return lexer keyword?

is javascript context-sensitive language?

added: point lexer not have t_return token, uses t_string instead. isn't?

return reserved keyword, reserved keywords can used property accessors without issue, it's bad practice so.

reserved keywords may not used names variables, functions, methods, or identifiers arrays , objects, because ecmascript specifies special behavior them:

the source text ecmascript scripts gets scanned left right , converted sequence of input elements tokens, control characters, line terminators, comments or white space.

ecmascript defines keywords , literals , has rules automatic insertion of semicolons end statements.

reserved words apply identifiers (vs. identifiernames).
described in es5, these identifiernames not exclude reservedwords.

a.return a["return"] = { return: "test" }. 

however these not

function return() {} var return; 

more on mdn


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -