Controlling DontEnum
# T. Michael Keesey (18 years ago)
On Thu, Mar 13, 2008 at 9:58 AM, Yuh-Ruey Chen <maian330 at gmail.com> wrote:
Not sure what ES4 policy is on how to pass "flags". Obvious method should be named parameters, but ES3/4 lack that feature. I also don't recall any ES3/4 method that uses bitflags (e.g. Object.READ_ONLY | Object.DONT_DELETE) or any variant of such flags.
"sortOptions - One or more numbers or defined constants, separated by the | (bitwise OR) operator, that change the behavior of the sort from the default. This argument is optional. The following values are acceptable for sortOptions:
* 1 or Array.CASEINSENSITIVE
* 2 or Array.DESCENDING
* 4 or Array.UNIQUESORT
* 8 or Array.RETURNINDEXEDARRAY
* 16 or Array.NUMERIC
[...]
"Note: The Array.sort() method is defined in the ECMAScript (ECMA-262) edition 3 language specification, but the array sorting methods are extensions to ECMA-262."
Garrett Smith wrote:
Not sure what ES4 policy is on how to pass "flags". Obvious method should be named parameters, but ES3/4 lack that feature. I also don't recall any ES3/4 method that uses bitflags (e.g. Object.READ_ONLY | Object.DONT_DELETE) or any variant of such flags. So that leaves strings (as you have), or an array of strings, both of which are less efficient. Hmm, this gives me an idea - more below.
That kind of defeats the purpose of setting all the flags during assignment, since this would allow you do so after assignment.
Ok, new suggestion based off previous ones:
obj.setProperty(prop, value) obj.setProperty(prop, value, Object.DONT_ENUM) obj.setProperty(prop, value, Object.READ_ONLY, Object.DONT_DELETE) obj.getPropertyAttribute(prop, Object.READ_ONLY) // returns true or false
BTW, names subject to change (could be just DONT_ENUM, or Object.dontenum, or whatever).
-Yuh-Ruey Chen