ES4 draft: Object

zwetan zwetan at gmail.com
Fri Mar 7 19:27:43 PST 2008


here some thought

why not have a global utility function, maybe in the magic namespace

SetPropertyFlag( reference:Object, name:*, setflag:int, unsetflag:int
= 0 ):Boolean

the flag could have this logic

| decimal | bitFlag | ReadOnly | DontDelete | DontEnum |
|              0|       000|                no|                  no|
              no|
|              1|       001|                no|                  no|
            yes|
|              2|       010|                no|                yes|
             no|
|              3|       011|                no|                yes|
           yes|
|              4|       100|              yes|                  no|
             no|
|              5|       101|              yes|                  no|
           yes|
|              6|       110|              yes|                yes|
            no|
|              7|       111|              yes|                yes|
          yes|


some usages:

someobj = { foo:123, bar:456 };

SetPropertyFlag( someobj, "foo", 0x110 );
SetPropertyFlag( someobj, ["foo","bar"], 0x001 );
//etc.


I personally would like to be able to do that also on the prototype
SetPropertyFlag( myAlmostNativeObject.prototype, [ "some",
"properties", "to", "protect" ], 0x011 );


cheers,
zwetan



More information about the Es4-discuss mailing list