I have an object of items used as a dictionary with key/value pairs:
var stuff = {};
stuff["jar"] = "biscuit";
I’m trying to remove an item. So far, no array method seems to work. Is this even an array (as you probably guessed, I’m not too crash hot on Javascript).
How do I remove an item?
delete stuff['jar']would remove ityou created an object literal and assigned the ‘jar’ property to be ‘biscuit’,
[]is the syntax for a true array, though in ECMAScript arrays are really objects and should be used for numerically indexed sets as opposed to key/value specific setsin short, you are using the right data type for the job.