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

  • Home
  • SEARCH
  • 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 8875801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:04:19+00:00 2026-06-14T19:04:19+00:00

Possible Duplicate: the delete operator in javascript I have the following code. I don’t

  • 0

Possible Duplicate:
the delete operator in javascript

I have the following code. I don’t understand why the second delete fails.

Also, I noticed that the foo function still exists even after I assigned something else to foo.

Is there a way to reference the function?
(suppose I’d want a bar2=foo() to behave like the bar assignment).

> function foo(){var bar=0; return function(){return bar++;}}
undefined
> bar = foo()
function () {return bar++;}
> bar()
0
> bar()
1
> delete bar
true
> foo = foo()
function () {return bar++;}
> foo()
0
> foo()
1
> delete foo
false

Thanks

  • 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-06-14T19:04:21+00:00Added an answer on June 14, 2026 at 7:04 pm

    delete only works on deleteable properties. Functions declared like this:

    function f(){
    }
    

    are not deleteable.

    Try using this syntax for the original function declaration:

    foo = function (){var bar=0; return function(){return bar++;}}
    

    See it here: http://jsfiddle.net/Sxnaw/

    You can go through this article for an in depth explanation of deleteable and non deleteable properties: http://perfectionkills.com/understanding-delete/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is it safe to delete a void pointer? Will the following code
Possible Duplicate: JavaScript Array Delete Elements So, in javascript, I have this set up:
Possible Duplicate: how to delete row from datagridview with a delete button? I have
Possible Duplicate: MySQL delete row from multiple tables I have 5 tables: members member_videos
Possible Duplicate: Deleting Objects in JavaScript I have a JS object having a large
Possible Duplicate: Deleting a pointer to const (T const*) void operator delete (void*); ...
Possible Duplicate: delete duplicate records in SQL Server I have a table in which
Possible Duplicate: Delete an array key when it contains a string in javascript by
Possible Duplicate: Delete object and all its child objects in Entity Framework? This code:
Possible Duplicate: How to delete an element from an array in php? I have

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.