ina
ina

Reputation: 19534

Javascript - possible to remove element of an associative array

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.

Upvotes: 2

Views: 719

Answers (1)

kennytm
kennytm

Reputation: 523514

To actually delete an element, use

delete array['knownkey'];

Upvotes: 2

Related Questions