JSFiddle - React, Tailwind, and code Playground

by Zaheer Ahmed

JavaScript

Array.prototype.remove = function() {
    var what, a = arguments, L = a.length, ax;
    while (L && this.length) {
        what = a[--L];
        while ((ax = this.indexOf(what)) !== -1) {
            this.splice(ax, 1);
        }
    }
    return this;
};
    
var myObject = [{
    "id": "1",
    "URL": "http://shsudhf.com",
    "value": "1"},

{
    "id": "2",
    "URL": "http://shsusadhf.com",
    "value": "2"},

{
    "id": "3",
    "URL": "http://shsudsdff.com",
    "value": "0"},
{
    "id": "2",
    "URL": "http://shsudsdff.com",
    "value": "0"}];

//Initially Length is 4
alert('Initially Length is :'+myObject.length);
myObject=deleteObject(myObject,2);
alert('After deleting Length is :'+myObject.length);

function deleteObject(array, id) {

    for (var o in array) {
       if (array[o].id == id)
            array.remove(array[o]);
    }
    return array;
   
}