Public Members can be accessed anywhere using the "." notation.
Private Members can only be accessed within a constructor and public method.
Public methods and variables are declared using the "this" keyword like "this.variableName".
A Public method is accessed using a constructor; this technique is usually used to initialize public instance variables.
var objPublicPrivateClassg = new PublicPrivateClass();
Code
- /*Comment
- <CodeItem type="Method">Class Name</CodeItem>
- <summary>Define the Class name as a function</summary>
- <params>
- </params>
- <return></return>
- Comment*/
- function PublicPrivateClass() {
- //PublicMethods
- this.publicMethods = {
- /*Comment
- <CodeItem type="Method">InitializePageControlEvents</CodeItem>
- <summary>Initialize the control</summary>
- <params>
- </params>
- <return></return>
- Comment*/
- InitializePageControlEvents: function () {
- privateMethods.PrivateTestMethod();
- }
- };
- // Private Methods
- privateMethods = {
- /*Comment
- <CodeItem type="Method">PrivateTestMethod</CodeItem>
- <summary>Show the alert Message</summary>
- <params>
- </params>
- <return></return>
- Comment*/
- PrivateTestMethod: function () {
- alert("Calling Private Method.");
- },
- PrivateTestMethod2: function () {
- alert("PrivateTestMethod2");
- }
- };
- }



Join the conversation! Your thoughts help the community grow.