Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

locate and delete an object in an array

 // we have an array of objects, we want to remove one object using only the id property
var apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
 
// get index of object with id:37
var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37);
 
// remove object
apps.splice(removeIndex, 1);
Comment

how to find and remove object from array in javascript

var id = 88;

for(var i = 0; i < data.length; i++) {
    if(data[i].id == id) {
        data.splice(i, 1);
        break;
    }
}
Comment

find object and remove in array

//remove object with id = 1 in an array
_.remove(array, (e) => {
	return e.id == 1
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: gif as animation react 
Javascript :: javascript new date undefined 
Javascript :: how to slice array in angular 6 
Javascript :: node fetch 
Javascript :: how to use javascript to hide content and show through link 
Javascript :: javascript dynamic variable name 
Javascript :: image to base64 js 
Javascript :: count length of a string javascript 
Javascript :: extends vs includes use case 
Javascript :: check if string Array javascript 
Javascript :: how to aadd variable in html tag in js 
Javascript :: how to check if an array contains a number in javascript 
Javascript :: Run Express in Production Mode 
Javascript :: v-bind shorthand 
Javascript :: modify array elements javascript 
Javascript :: chrome extension catch shortcut 
Javascript :: delete request from the script to html 
Javascript :: datatable dropdown toggle not working 
Javascript :: object find javascript 
Javascript :: convert int to string javascript 
Javascript :: angular erro ao adicionar um projeto no firebase Failed to make request to https://www.gstatic.com/firebasejs/releases.json 
Javascript :: Javascript Unordered List HTML form Array 
Javascript :: header react native 
Javascript :: three dots in javascript 
Javascript :: set radgrid datasource clientside 
Javascript :: js intellisence not working 
Javascript :: javascript close calendar after select 
Javascript :: LocomotiveScroll npm 
Javascript :: install svelte routing 
Javascript :: repeat call n times in js 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =