HI

You can't use reserved words as variables or function names. You can
use them as object properties, but only if they're passed in as a
string (by wrapping them in quotation marks)

var o = {delete: true}; // causes an error because delete is a
reserved word.
o.delete; // same error as before.

var o = {"delete": true}; // fine.
o['delete']; // true

If you're looking for a full list of reserved words, try the page at
MDC: https://developer.mozilla.org/en/JavaScript/Reference/reserved_words

Hope that clears a few things up

On Aug 27, 8:05 pm, xavierm02 <[email protected]> wrote:
> Hi,
>
> I was wondering when it was allowed to use reserved words. Let's say
> "delete".
>
> If you do this :
>
> var o = {
>     'delete': true
>
> };
>
> everything is fine.
>
> If you do this :
>
> var delete = true;
>
> You get an error and this is perfectly normal since if you had no error,
> then
>
> delete( whatever );
>
> Which is a correct syntax to use the delete operator would also have to call
> your delete function, if you created a function named delete.
>
> But then what about this :
>
> var o = {
>     delete: true
>
> };
>
> It goes well in Chrome and JSLint cries.
>
> Can it be used that way?
>
> And what about
>
> o.delete;
>
> ?
>
> I don't really understand where you can use reserved words and where you can
> not...

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to