I want to delete a couple of object properties, but first save those
properties, then add them back after I'm done processing the object
*without* those properties.
But I can't do the following, when I log the object to the console,
it's apparent the properties didn't get deleted, presumably because to
do so would leave dangling references, i.e. the two vars:
var title = '' + this.args.title;
var mode = '' + this.args.mode;
delete this.args['title'];
delete this.args['mode'];
One way to work around this use some of Javascript's awful parts
according to Crockford is:
var title = new String(this.args.title);
var mode = new String(this.args.mode);
with (this.args) {
delete title;
delete mode;
}
Between this and my use of "new Number(0)" earlier, I'm breaking all
the rules today, as I presume is bound to happen when you've been
tinkering with Javascript 12 years or so ;)
Finally I settled on this:
var title = '' + this.args.title;
var mode = '' + this.args.mode;
delete this.args['title'];
delete this.args['mode'];
Feedback appreciated....George
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]