The visibility of a property or method can be defined by prefixing the declaration with the keywords public, protected or private. Class members declared public can be accessed everywhere. JOII makes no distinction between members declared protected or private when it comes to visibility. The difference in private and protected is that protected properties will have getters and setters generated for them which are only accessible from inside the class scope.

Protected properties will have getters and setters generated that are only accessible from inside the class or inside any classes extending on it.

var MyClass = Class({

    // Declare a public property
    'public string my_public_string' : 'This is public',

    // Declare a protected property
    'protected string my_protected_property' : 'This is protected',

    // Declare a private property
    'private string my_private_string' : 'This is private',

    // Declare a public method
    'public myPublicMethod()' : function () {
        // This exists:

        // This does not:

        // However, you can still access the my_private_string variable from within all class methods:
        return this.my_private_string;

    // No visibility = public.
    'string another_public_string' : 'Another public string!'

var my_class = new MyClass();

my_class.getMyPublicString();      // "This is public"
my_class.getMyProtectedString();   // Error: method is undefined
my_class.getMyPrivateString();     // Error: method is undefined
my_class.my_private_string;        // undefined
my_class.myPublicMethod();         // "This is private"
my_class.getAnotherPublicString(); // "Another public string!"