如何从javascript关联数组中删除对象? - How do I remove objects from a javascript associative array?

问题:

Suppose I have this code: 假设我有这个代码:

var myArray = new Object();
myArray["firstname"] = "Bob"; myArray["lastname"] = "Smith"; myArray["age"] = 25; 

Now if I wanted to remove "lastname"?....is there some equivalent of 现在,如果我想删除“姓氏”?....是否有一些相当于
myArray["lastname"].remove() ? myArray["lastname"].remove() ?

(I need the element gone because the number of elements is important and I want to keep things clean.) (我需要元素消失,因为元素的数量很重要,我想保持清洁。)


解决方案:

参考一: https://stackoom.com/question/1S0z/如何从javascript关联数组中删除对象
参考二: https://oldbug.net/q/1S0z/How-do-I-remove-objects-from-a-javascript-associative-array

来源:泰州网站优化

猜你喜欢

转载自www.cnblogs.com/vwvwvwgwg/p/12892273.html
今日推荐