Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6169379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:50:54+00:00 2026-05-23T22:50:54+00:00

I am wondering how JavaScript’s reserved keywords / functions are managed. Example: According to:

  • 0

I am wondering how JavaScript’s reserved keywords / functions are managed.

Example:

According to:

http://www.quackit.com/javascript/javascript_reserved_words.cfm

delete is a reserved keyword by JavaScript.

Then consider the following snippet for some context:

var cookieManager = {
    get: function (name) { 
        // function contents ...
        console.log("cookieManager.get() called");
        return true;
    },
    set: function (name, value, days) {
        // function contents ...
        console.log("cookieManager.set() called");
        return true;
    },
    delete: function (name) { 
        // function contents ...
        console.log("cookieManager.delete() called");
        return true;
    }
};

This object has a delete property, yet the name of it is reserved by JavaScript so it should fail, right?

Yet when I execute cookieManager.delete(); in the webconsole of FireFox I get the following output, suggesting that it works fine:

[11:26:00.654] cookieManager.delete();
[11:26:00.656] cookieManager.delete() called
[11:26:00.657] true

If, however, you run the code in JsLint it says

Problem at line 12 character 5: Expected an identifier and instead saw 'delete' (a reserved word).

delete: function (name) { 

Suggesting that this is a big no no approach and should be avoided.

So when should I take reserved keywords into consideration, as in this example it seems to work just like I want it to ( the delete keyword is in the context of the object cookieManager and thus causes no conflicts, hence it can be used ) or should I abide to the bible that is JsLint and rename anything that is a reserved keyword by javascript? In this context I could easily rename .delete() to .remove().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:50:54+00:00Added an answer on May 23, 2026 at 10:50 pm

    Actually this is allowed as per ECMAScript specification. The production rules (Section 11.1.5) for an object literal are:

    ObjectLiteral :
        {}
        {PropertyNameAndValueList}
        {PropertyNameAndValueList  ,}
    
    PropertyNameAndValueList :
        PropertyAssignment
        PropertyNameAndValueList , PropertyAssignment
    
    PropertyAssignment :
        PropertyName : AssignmentExpression
        get PropertyName ( ){FunctionBody}
        set PropertyName (PropertySetParameterList){FunctionBody}
    
    PropertyName :
        IdentifierName
        StringLiteral
        NumericLiteral
    

    In your case, you use an IdentifierName as property name. Section 7.6.1 says:

    A reserved word is an IdentifierName that cannot be used as an Identifier.

    Note the difference: You cannot use a reserved keyword as Identifier, but as it is a valid IdentifierName you can use it as PropertyName.


    Nevertheless, other (versions of) browsers might not tolerate this, so to be on the safe side, I would rename it.

    Apart from possible problems with browsers, it might also confuse others who read your code and are not familiar with this rule.


    FWIW, of course you can always use reserved keywords as strings:

    var a = {'delete': 'foo'};
    alert(a['delete']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if Javascript date/time functions will always return correct, universal dates/times or
Wondering how to open many new windows with Javascript. I have found plenty of
I'm relatively new to Javascript and was wondering if there's a quick way to
I was wondering if anyone has any preference for referencing images/ css or javascript
Reading through this question on multi-threaded javascript, I was wondering if there would be
I'm just wondering which JavaScript library/toolkit works the best with ASP.NET MVC? Is it
I was wondering why JavaScript has such a confusing API. It is not consistent
I am wondering if JavaScript supports writing a function within another function, or nested
I know PHP has call_user_func , I was just wondering if JavaScript had something
Hey this question is pretty general, but I'm wondering what the Javascript differences are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.