Public

The members of an object are all public members. There are two ways for putting members in a new object.

In Constructor

function Container(param) {
    this.member = param;
}

In the prototype

This technique is used to add public methods.

Container.prototype.stamp = function (string) {
    return this.member + string;
}

Private

Private members are made by the constructor. Ordinary vars and parameters of the constructor become the private members.

function Container(param) {
    this.member = param;
    var secret = 3;
    var that = this;
}

Privileged

A privileged method is able to access private methods, variables and is itself accessible to the public method and the outside.  Privileged methods are assigned with “this” within the constructor.

function Container(param) {
    this.member = param;

    this.service = function () {
        return this.member;
    };
}

 

References: