简体   繁体   中英

How do I remove associative array from javascript?

I found the way to delete an item of associative array by :

delete array['knownkey'];

but what about delete the whole associative array,I mean just like empty an normal array:

the way to empty an normal array is [I found on the google]:

array = []  //or
array.length = 0 

So,the associative array has the way to empty or remove the all items at once ....

assoc_array = {};

Should set assoc_array to an empty object (aka associative array in JavaScript).

Thanks to garbage collection, there is no real need to empty an existing object. You just go get a new one.

What's wrong with:

array = {}

..?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM