tags:

views:

1030

answers:

7

What Javascript keywords (function names, variables, etc) are reserved?

+17  A: 

http://javascript.about.com/library/blreserved.htm lists them quite nicely.

robintw
+5  A: 

We should be linking to the actual sources of info, rather than just the top google hit.

http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words

JSscript 8.0: http://msdn.microsoft.com/en-us/library/ttyab5c8.aspx

I'll look for ECMAScript links later.

benc
+4  A: 

To supplement benc, see Standard ECMA-262. These are the official reserved words, but only a pedant ignores the implementation to respect the standard. For the reserved words of the most popular implementations, that is firefox and internet explorer, see benc's answer.

The reserved words in EMCAScript-262 are the Keywords, Future Reserved Words, NullLiteral, and BooleanLiterals, where the Keywords are

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

the Future Reserved Words are

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

the NullLiteral is

null

and the BooleanLiterals are

true
false
Joseph Holsten
Joseph, thanks for adding that info. I found that PDF in google, but didn't have time to open and read it all.
benc
A: 

This is one of the many things discussed in "JavaScript: The Good Parts" by Douglas Crockford.

By the way, I'm not affiliated with the publisher; The book is just that awesome.

Chris Pietschmann
A: 

I discovered today that the word "keywords" is a reserved word in IE javascript. It turns out to be an object that contains a list of all the keywords. No errors are generated if you try and use this as a variable, but any time you try and access the value of your variable you get an object back instead of what you assigned to it. Arg!

Dan
+1  A: 

item is also a reserved word in Javascript for IE

Duane G
This isn't quite true. As far as I can tell, "window.item" is reserved. This means that using "item" as a variable without first explicitly scoping it with "var" will cause an error.
David
A: 

header and footer just broke my script in IE8.

HdotNET