[Helma-dev] new experimental object.dontEnum() function
Hannes Wallnoefer
hannesw at gmail.com
Thu Sep 8 21:52:23 CEST 2005
I just committed support for a new dontEval() function on the Object
prototype. Calling this with a variable number of string arguments
will cause the DONTENUM attribute to be set on the given properties so
they won't be included in for..in loops on the object.
This will be very useful when we extend standard prototypes like
Object.prototype and Array.prototype in helmaLib. Some example code:
var obj = {foo: "bar", bar: "foo"};
obj.dontEnum("bar", "foo");
for (var i in obj)
res.debug(i);
Some closer to real world sample code might look like this:
Array.prototype.indexOf = function(obj) { ... }
Array.prototype.lastIndexOf = function(obj) { ... }
Array.prototype.dontEnum("indexOf", "lastIndexOf");
Should we use some more frightening name, such as __dontenum__() to
underscore the non-standardness of this feature?
hannes
More information about the Helma-dev
mailing list