On Apr 10, 8:36 pm, chrysanthe m <[email protected]> wrote:
> Hi, again
> Sorry for being obtuse. But can someone help me and even understand how to
> write a function and call it on a hash that will take a value, compare it
> against each of the keys in the hash, on match delete the key/value, and
> return the hash. tia.
Consider using a plain object:
var o = {foo:'foo', bar:'bar'};
function removeProperty(obj, prop) {
if (prop in obj) {
delete obj[prop];
} else {
return prop + ' not in object';
}
}
alert(o.foo);
removeProperty(o, 'foo');
alert(o.foo);
No need to "return" the object, it is modified in place.
--
Rob
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.