Previous Page
Next Page

B. JavaScript Reserved Words

Reserved words are words that have special meaning to JavaScript. Therefore, they cannot be used as variable or function names.

You'll recognize many of the reserved words from previous chapters, but others will be unfamiliar. Some of the latter group are future reserved words; i.e., it's expected that they'll be commands in future versions of JavaScript. They're being set aside now so that you won't have to revise your code when new revisions are released.

JavaScript reserved words:

These words are part of the JavaScript language as of ECMAScript version 3.

break

for

throw

case

function

try

catch

if

typeof

continue

in

var

default

instanceof

void

delete

new

while

do

return

with

else

switch

 

finally

this

 


Additional words reserved for future use by ECMAScript 3:

abstract

final

protected

boolean

float

public

byte

goto

short

char

implements

static

class

import

super

const

int

synchronized

debugger

interface

throws

double

long

TRansient

enum

native

volatile

export

package

 

extends

private

 


ECMAScript 4:

As of this writing, ECMAScript version 4 has not been finalized. These words are likely to be added to the reserved words list, so you should avoid using them:

as

namespace

use

false

null

 

is

TRue

 


These words are likely to no longer be reserved, but we recommend that you still avoid using them:

boolean

final

short

byte

float

static

char

int

 

double

long

 


Other identifiers to avoid:

The object names used in Appendix A aren't officially reserved (outside of the keywords above), but as they are part of the JavaScript language, you shouldn't use them as function or variable names. If you do, abandon all hope; the results will be unpredictable.

In addition, most browsers are case-sensitive, which means that they differentiate between Document and document. Internet Explorer is only sometimes case-sensitive, which means that, for example, it may not understand any difference between Document and document. Consequently, be aware that just because it works in one browser doesn't mean that it'll always work in others. Test, test, test.


Previous Page
Next Page