Controlling DontEnum

# Yuh-Ruey Chen (18 years ago)

Garrett Smith wrote:

The order of the boolean parameters is kind of annoying to have to remember.

Would it be OK to shorten the method?

obj.setProperty("c"); // undefined value obj.setProperty("c", 2); obj.setProperty("c", undefined, "dontenum", "readonly"); obj.setProperty("c", undefined, "dontdelete");

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.

-- or --

obj.setProperty("c", undefined). // Reference type. dontEnum(). readOnly(). dontDelete();

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

# 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.

From livedocs.adobe.com/flex/3/langref/Array.html#sort() :

"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."