Author:   Slightboy,   Time:   The 2006-10-17
this article for   Js  Implement version,   As before has confessed the principle   So not to do more to explain here
if you want to introduce principle   Please check   VBs  Version.
var  PermissionType =
{
        Read  :   1,
        Write  :   2,
        Delete  :  

4} function  PermissionSetComponent (value)
{
        This. Value =  The value;
        This. GetRead =  The function ()
        {
                Return  This getValue (PermissionType. Read);
        }
        This. SetRead =  The function (value)
        {
                Enclosing setValue (PermissionType. Read   value);
        }
        This. Read =  The function ()
        {
                If  (the arguments. Length  >  0)
                        Enclosing setValue (PermissionType. Read   the arguments [0]).
                The else
                        Return  This getValue (PermissionType. Read);
        }
        This. Write =  The function ()
        {
                If  (the arguments. Length  >  0)
                        Enclosing setValue (PermissionType. Write,   the arguments [0]).
                The else
                        Return  This getValue (PermissionType. Write);
        }
        This. Delete =  The function ()
        {
                If  (the arguments. Length  >  0)
                        Enclosing setValue (PermissionType. Delete,   the arguments [0]).
                The else
                        Return  This getValue (PermissionType. Delete);
        }
        This. GetValue =  The function (permissionType)
        {
                Return  (this Value  &  permissionType)  ==  PermissionType;
        }
        This. SetValue =  The function (permissionType,   value)
        {
                If  (value)
                        This. Value  |=  PermissionType;
                The else
                        This. Value  &=  ~ permissionType;
        }

} var  PermissionSet =  New  PermissionSetComponent (0);
w (Read: ");
PermissionSet. Read (false);
w (PermissionSet. Value  + " " +   PermissionSet. Read ());
PermissionSet. Read (true);
w (PermissionSet. Value  + " " +   PermissionSet. Read ());
w (" Write: ");
PermissionSet. Write (false);
w (PermissionSet. Value  + " " +   PermissionSet. Write ());
PermissionSet. Write (true);
w (PermissionSet. Value  + " " +   PermissionSet. Write ());
w (" Delete ");
PermissionSet. Delete (false);
w (PermissionSet. Value  + " " +   PermissionSet. Delete ());
PermissionSet. Delete (true);
w (PermissionSet. Value  + " " +   PermissionSet. Delete ());
function  W (o)
{
        Response. Write (o  + "}
note:   The red part is   Java  Style of writing   Not needed in this case.
just do a show,   If you prefer   Java  Style can also choose this kind of writing.


This concludes the body part