我得到了一个里面有对象的数组,这些对象里面有元素。我将如何通过元素之一来寻址这些对象之一?
let randomARR = [];
let a = {"name": "John", "age": 20, "PlaceOfBirth": "Germany"};
let b = {"name": "Simon", "age": 20, "PlaceOfBirth": "France"};
let c = {"name": "Michael", "age": 20, "PlaceOfBirth": "USA"};
randomARR.push(a);
randomARR.push(b);
randomARR.push(c);
结果:
[{"name": "John", "age": 20, "PlaceOfBirth": "Germany"}, {"name": "Simon", "age": 20, "PlaceOfBirth": "France"}, {"name": "Michael", "age": 20, "PlaceOfBirth": "USA"}]
假设我想通过对象的元素"name"寻址对象,而不是它在数组中的位置,将对象 b (name: Simon) 从数组中删除。
繁星点点滴滴
慕哥9229398
相关分类