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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:25:17+00:00 2026-05-16T04:25:17+00:00

i have this json structure and I made it into an array. I was

  • 0

i have this json structure and I made it into an array. I was trying to remove the entry, but this code failed on me: Remove item from array if it exists in a 'disallowed words' array

var historyList = []; // assuming this already has the array filled

function add() {
     var newHistory = {
                ID: randomString(),
                Name: $('#txtVaccineName').val(),
                DoseDate: doseDate,
                ResultDate: resultDate,
                Notes: $('#txtResultNotes').val()
            };
     historyList.push(newHistory);
};

function removeEntry(value) {
  historyList.remove('ID', value);
};

Array.prototype.remove = function(name, value) {
            array = this;
            var rest = $.grep(this, function(item) {
                return (item[name] != value);
            });

            array.length = rest.length;
            $.each(rest, function(n, obj) {
                array[n] = obj;
            });
        };
  • 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-16T04:25:18+00:00Added an answer on May 16, 2026 at 4:25 am

    You could use a property filter to match the item in your history list. Below is the sample quick code to do so, I’ve modified your history list a bit.

    A quick test in FF, shows that it works!

    var historyList = []; // assuming this already has the array filled
    
    function addToHistory(name, notes) {
         var newHistory = {
              ID: new Date().getTime(),
              Name: name,
              DoseDate: "Somedate",
              ResultDate: "SomeResultDate",
              Notes: notes,
              toString: function() {return this.Name;}
         };
         historyList.push(newHistory);
    };
    
    var Util = {};
    
    /**
     * Gets the index if first matching item in an array, whose
     * property (specified by name) has the value specified by "value"
     * @return index of first matching item or false otherwise
     */
    Util.arrayIndexOf = function(arr, filter) {
       for(var i = 0, len = arr.length; i < len; i++)  {
          if(filter(arr[i]))   {
             return i;
          }
       }
       return -1;
    };
    
    /**
     * Matches if the property specified by pName in the given item,
     * has a value specified by pValue
     * @return true if there is a match, false otherwise
     */
    var propertyMatchFilter = function(pName, pValue)  {
       return function(item) {
          if(item[pName] === pValue) {
             return true;
          }
          return false;
       }
    }
    
    
    /**
     * Remove from history any item whose property pName has a value
     * pValue
     */
    var removeHistory = function(pName, pValue)   {
       var nameFilter = propertyMatchFilter(pName, pValue);
       var idx = Util.arrayIndexOf(historyList, nameFilter);
       if(idx != -1)  {
          historyList.splice(idx, 1);
       }
    };
    
    
    // ---------------------- Tests -----------------------------------
    addToHistory("history1", "Note of history1");
    addToHistory("history2", "Note of history2");
    addToHistory("history3", "Note of history3");
    addToHistory("history4", "Note of history4");
    
    alert(historyList); // history1,history2,history3,history4
    
    removeHistory("Name", "history1");
    
    alert(historyList); // history2,history3,history4
    
    removeHistory("Notes", "Note of history3");
    
    alert(historyList); // history2,history4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java data structure which results from deserialising this JSON: { 'level1
I have some data and need to create a json file with this structure
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
i have this JSON: var projects_array = new Array( {name:myName1, id:myid1, index:1}, {name:myName2, id:myid2,
I have this XML structure that I wish to construct in JSON format using
I have a json structure that I'm decoding that looks like this: person =>
I have a JSON file and i have to read data from this file
I have somewhat deep Json structure like below incoming over the wire into C#
I am having trouble on formatting my json. Basically I have this script structure,
I have a json structure that looks something like this: list:[ { type:link, href:http://google.com

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.