[Javascript] Error: missing name after . operator

liorean liorean at gmail.com
Fri Oct 28 08:20:20 CDT 2005


On 28/10/05, shashidhar.vutukuru at wipro.com
 <shashidhar.vutukuru at wipro.com> wrote:
> When I try and get its  value using
>      document.forms[0].interface.value;
> I get this  error:
>      "Error: missing name after . operator"

"interface" is indeed a future reserved keyword in ECMAScript. See the
end of this post for the full list.

You can easily fix this problem by using
    document.forms[0].elements['interface'].value
instead.

> This happens only  in firefox and Netscape but not in IE.
> Is interface an  keyword.. and should it  not be used?
> then why does not  it throw an error in IE also..?

Because JScript isn't 100% compliant to ECMAScript. (No JavaScript
engine is, but some are more and some are less compliant)




ECMAScript Language Specification Edition 3 24-Mar-00

7.5.2 Keywords
The following tokens are ECMAScript keywords and may not be used as
identifiers in ECMAScript programs.
Syntax

Keyword :: one of
break       else        new         var
case        finally     return      void
catch       for         switch      while
continue    function    this        with
default     if          throw
delete      in          try
do          instanceof  typeof

7.5.3 Future Reserved Words
The following words are used as keywords in proposed extensions and
are therefore reserved to allow for the
possibility of future adoption of those extensions.
Syntax

FutureReservedWord :: one of
abstract    enum        int         short
boolean     export      interface   static
byte        extends     long        super
char        final       native      synchronized
class       float       package     throws
const       goto        private     transient
debugger    implements  protected   volatile
double      import      public
--
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>



More information about the Javascript mailing list