2

Is it possible to remove an element of a Javascript associative array (i.e., set back to native undefined)?

When I tried simply alert(array['knownKey']); array['knownKey']=undefined; alert(array['knownKey']); ... the second alert produced the literal undefined... whereas, the first alert returned nothing.

ina
  • 19,167
  • 39
  • 122
  • 201
  • 1
    possible duplicate of [Delete a key from an associative array](http://stackoverflow.com/questions/1754777/delete-a-key-from-an-associative-array) – kennytm Aug 13 '10 at 08:23

1 Answers1

2

To actually delete an element, use

delete array['knownkey'];
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005