views:

70

answers:

2

Some SPECIAL words such as Object, Array, Function, Method, Number etc are not belong to keywords in Javascrpt: Reserved Keywords in Javascript.

But I have to use them carfully, they are not NORMAL words as object, array, method, number, foo ...

I'd like to know how many such SPECIAL words we have? Pls give me the list.

A: 

"function" is actually a reserved word.

The other special words you list (although I'm not sure about "Method"?) are predefined JavaScript Classes and Objects. And possibly Global Properties and Methods.

EDIT: With reference to the list provided at developer.mozilla.org/en/JavaScript/Reference/Global_Objects - this appears to be a list of the core JavaScript Objects, irrespective of whether the JavaScript engine is running in the browser or not. This is a sub-list of the list provided at About.com. Although why 'Boolean' is omitted from the list of Global Objects at About.com I don't know - this does appear to be an omission?

Other objects defined by the (Mozilla) browser/DOM are listed in the Gecko DOM Reference.

w3d
I mean Function, not function.
John
@John Sorry, yes, "Function" (capital 'F') is a predefined object.
w3d
@w3d Matt Hall give me http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects, which is different to your list, especially for Function, I am still somehow confused.
John
@John I have updated my answer, but 'Function' is included in both lists as a predefined global object.
w3d
A: 

It all boils down to one thing, really: JavaScript is case sensitive. That's why it makes a distinction between Object and object.

Object, Array, Function and Number are not keywords, nor are they exactly "special" (whatever you think they mean) words.

They're nothing more than built-in function/class types in JavaScript (you can do a typeof on them and see). You don't directly use them often now though since there are syntactic alternatives to creating objects of each of those types, for example:

var obj = {};
var func = function() {};
var arr = [];
var num = 123;

The others you mention (object, array, method, number, foo) aren't keywords or "special" words either simply because, since as I say JavaScript is case sensitive, they mean nothing in JavaScript compared to their capitalized counterparts. Unless, of course, you give them meaning yourself by declaring variables with those names.

BoltClock
Thanks, BoltClock. where can I find all these built-in function/class types in JavaScript?
John
@John: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
Matt Ball
@Matt Ball, w3d gives two links are different from yours, any comments?
John
@John: Mozilla's JavaScript documentation is *official* as they are the developers and maintainers of the JavaScript scripting language.
BoltClock
@John: JavaScript is an implementation of the ECMA-262 language specification - [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript) - and yes, as BoltClock said, Mozilla (Foundation) is _the_ JavaScript developer: http://en.wikipedia.org/wiki/Javascript (see the sidebar on the right).
Matt Ball
Wikipedia is a bit misleading about what "JavaScript" is. So JavaScript is Mozilla's ES implementation, OK... But if you're going to say that instead of "javascript is a generic term for ES implementations, including Moz's JavaScript, MS's JScript, etc." then how the heck can you call V8 a "JavaScript Implementation?" Very misleading.
no