Delete operator in JavaScript
One of the lesser known operators in JavaScript is the 'delete' operator. I came to know about this operator when I was searching for a way to delete an element of an associative array.
The Mozilla Reference Docs have this to say about the delete operator...
The delete operator deletes an object, an object's property, or an element at a specified index in an array.
Usage
var arr = {
"number": 42,
"year" : 2007,
"hello" : "world",
"foo" : "bar"
}
for(var ele in arr) {
alert(ele + " : " + arr[ele]);
}
delete arr['hello']; //Removes the 'hello' key of the array
for(var ele in arr) {
alert(ele + " : " + arr[ele]); //The 'hello' key and its value will be missing
}
Compactability
I tested it in Firefox 2.0 and IE 6 - it works in both cases. If you test it in other browsers, post the results in the comment section.

Comments
great.
for initerations.You're merely referencing via string (a.k.a. what people who can't program do)
B) Javascript never really deletes anything. Instead, it sets the value to undefined.
In javascript, all namespaces are filled with undefined so it's IMPOSSIBLE to actually delete a namespace. What you can do, however, is delete the values stored in said namespaces.
I'm looking into it, but its purpose should be to guarantee the destruction of an object after you're finished using it. (As far as I'm aware, the values stored in a particular namespace (inclusive of heirachy) are never removed unless the value is explicitly change.
Thus, we delete values that will persist after the code is executed that we do not need around the next pass through.
C)
var a = new Array(5);
a.splice(3,1);
Is the way you remove elements from a REAL array
D) Don't be a Noob, learn how to program before you learn how to script.
I want to delete a particular row when i am clicking a delete button that row should get deleted.and the same page containing remaining data should be uploaded.The existing page is containing thye actions for modifications.
when i am deleting the data from the existing page it is directed to the modification page.
please suggest an answer to this
thank u!!!!!
www.dustindiaz.com/add-remove-elements-reprise/
^^
;-)
working in Prism 1.05
var myObject = { a:["a","b"], b:"x"}
alert(myObject.a)
delete myObject.a
alert(myObject.a)
a, strong, em, b, i, code, pre, pandbrallowed. Other tags will be shown as code(< will become <). Urls, Line breaks will be auto-formated.