We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Reserved Words

>Mozilla will likely reserve these keywords in normal code in a future release, to conform to the specification ...

Is this really true?

I don't think so - ECMA-262 V5 states that reserved keywords may not be used as Identifiers which has a very strict definition:

Identifier ::
    IdentifierName but not ReservedWord
    IdentifierName ::
        IdentifierStart IdentifierName IdentifierPart

It also states:

Two IdentifierName that are canonically equivalent according to the Unicode standard are not equal unless they are represented by the exact same sequence of code units

This is after replacement of any Unicode escape sequences and two Identifiers are not considered equal unless they match bitwise
Any reserved Keyword as described in ECMA-262 V5, 7.6.1 may not be used as Identifiers so:
var if; is invalid because it exactly matches a reserved keyword (var If; capitalized is ok)

Valid (simultaneous) Identifiers may/should be:

var myVar = 'string';
var myObj = {};
myObj.myVar = '';
myObj.myObj = null;
myObj.if = '';
myObj.typeof = 'Object';

myVar may coexist with myObj.myVar, myObj.myObj causes no confusion and myObj.typeof can't be mistaken for the reserved keyword typeof - the are not equal by definition

The same is true for any reserved word used as part of an Identifier - as long as they don't match there is no problem and should be allowed

I see no reason to impose unneeded rules for people to follow, especially when there is no other effect than a limitation of rational possibilities

> ... and to be consistent with other browsers

Opera and Safari are the only browsers that do not accept using reserved keywords as part of identifiers so it might be better if they change theirs to conform to the rest of the world?

Document Tags and Contributors

Contributors to this page: MarcelKorpel, terje.rosenlund
Last updated by: MarcelKorpel,