views:

366

answers:

3

I'm using an ASP "classic" server, with JavaScript as the language engine, specified by the directive:

<%@LANGUAGE='JAVASCRIPT'%>

I've noticed that `import' seems to be a keyword.

Technical Information (for support personnel)

    * Error Type:
      Microsoft JScript compilation (0x800A03F2)
      Expected identifier
      /Default.asp, line 4, column 4
      var import = 'whut'
      ---^

How is the `import' keyword used, if at all?

A: 

From here:

The import statement allows a script to import properties, functions and objects exported by a signed script. The following code imports the 'wine' and 'beer' properties of the object 'drinks' provided they have been made available by an exporting script (compare the export statement):

Code: import drinks.beer, drinks.wine;

NOTE: Any exported script must be loaded into a window, frame or layer before it can be imported and used.

Andrew Hare
Thanks, Andrew. I have tried to use this syntax with a made up export, but it seems to still show a syntax error:Error Type:Microsoft JScript compilation (0x800A03EA)Syntax error/Default.asp, line 4import drinks.beer, drinks.wine;I would not expect a syntax error here. What do you think?
Christopher Done
+1  A: 

Like in most programming languages, certain keywords are reserved. Javascript is a bit special since it reserves more keywords than are implemented in the language. Import is one of those words. Other examples are 'private' and 'void', though they are not implemented in the current releases.

Helgi
void is implemented, albeit not really usefull.
KooiInc
Quite right RK, my fault..
Helgi
A: 

import is a reserved word in js, but I think it is only actually used in JScript.NET and ActionScript.

Nathan L Smith