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
  • 18,561
  • 37
  • 117
  • 197
  • 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
  • 491,404
  • 99
  • 1,053
  • 989