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 8058933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:30:22+00:00 2026-06-05T09:30:22+00:00

I have an array of objects where the key is an md5 string and

  • 0

I have an array of objects where the key is an md5 string and the value is an object
[0315778255cca8d2f773642ad1d3678f] = {a:12,b:34}. I need to remove array elements based on their key, i tried splice but failed cause i suppose the keys are non numeric.
I also tried to splice by position, but that failed to, and even delete the element but we all know that it is not ideal.

I could change my implemantation from array to object but that too will have the same problems more or less i suppose.

Any ideas are welcome

  • 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-05T09:30:24+00:00Added an answer on June 5, 2026 at 9:30 am

    splice is indeed about the array indexes (as the numeric properties of arrays are called), not about other properties.

    To remove a property from an object (including an array), use delete:

    delete theArray['0315778255cca8d2f773642ad1d3678f'];
    

    Despite its similarity to “delete” in other languages, delete in JavaScript has nothing (directly) to do with memory management; all it does is remove a property from an object (entirely; it doesn’t just set the property’s value to undefined or something).

    Side note: If you’re only using non-numeric properties, you probably don’t want an array at all. The only reason for using JavaScript’s Array type is if you need the special handling it gives properties whose names are all digits, the magic length (which only relates to the numeric properties), and the stuff from Array.prototype — none of which does anything with other, non-index properties.


    Re your comment below:

    delete leaves an undefined in the elements place. i need to get rid of it completely

    No, delete removes the property, entirely. It does not leave undefined in its place. You might be thinking it does because any time you try to retrieve a property from an object that doesn’t exist, you get back undefined. E.g.:

    var obj = {};            // Object with no "foo" property at all
    var x = obj.foo;
    console.log("x = " + x); // "x = undefined"
    

    You can prove that the property really is removed by using hasOwnProperty or in:

    var obj = {};
    console.log('foo' in obj);              // "false"
    console.log(obj.hasOwnProperty('foo')); // "false"
    

    in will check the object and its prototype chain; hasOwnProperty just checks the object itself.

    Coming back to delete:

    var obj = {};
    console.log(obj.hasOwnProperty('foo')); // "false"
    obj.foo = "bar";
    console.log(obj.hasOwnProperty('foo')); // "true"
    delete obj.foo;
    console.log(obj.hasOwnProperty('foo')); // "false"
    obj.foo = "bar";
    console.log(obj.hasOwnProperty('foo')); // "true"
    delete obj['foo'];
    console.log(obj.hasOwnProperty('foo')); // "false"
    

    Live example | source

    Note that both delete obj.foo; and delete obj['foo']; work if foo is a valid identifier. But for properties whose names aren’t valid identifiers (like your md5 sums), you have to use the bracketed form with the string as I showed above (delete theArray['0315778255cca8d2f773642ad1d3678f'];).

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

Sidebar

Related Questions

I have an array of objects with several key value pairs, and I need
I have an array of objects and I need them sorted by their title
I have an array of objects that have 2 properties: Key and Value. I
How can check if an array of objects have a key value using underscore.
I have an array of JSON objects, some of which contain key/value pairs for
i have an array list of custom objects. each object contains a value i
I have an array of objects in MATLAB and I've called their constructors in
I have an array of objects . Each object has an attribute we'll call
What's the fastest/one-liner way to remove duplicates in an array of objects, based on
I have an array of objects: Object = { 1 : { name :

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.