Guest, register

OOP JavaScript: Public and Private Methods Through this simple JavaScript tutorial, you would learn about Public and Private methods in the JavaScript OOP.

Label: OOP, Public, Private, Method

Free iPage Web Hosting for First Year NOW

If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with $1.89/month, included $500+ Free Extra Credits for the payment of 24 months ($45)?

Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you register the web hosting at iPage through our link, we're going to be happy for resending a full refund to you. That's awesome! You should try iPage web hosting for FREE now! And contact us for anything you need to know about iPage.
Try iPage for FREE First Year NOW

At Ning, here's how we do public and private methods in JavaScript:

* A scrollable list that can display large numbers of contacts.
* @param contacts contact objects
xp.ContactSelector = function(args) {

/** Container for public functions. */
var self = {};

/** Container for private functions. */
var _ = {};

* Initializes the object.
_.initialize = function() {
if (!args.contacts) {

* Adds a searchbox to the ContactSelector.
_.installSearchbox = function() {
// This is a private method

* Returns the contacts that the user has selected
* @return the selected contact objects
self.getSelectedContacts = function() {
// This is a public method

. . . . . . . . . .

return self;

Private methods begin with _., while public methods begin with self.. There are some interesting things about this setup:
  • Public methods are accessible on the object created by this function. Private methods are not accessible.
  • Public and private methods can be defined in any order, regardless of which calls which. This is because they are properties of self and _. If they were defined as standalone functions, then order would matter.
  • You can inherit from another object by adding the following to initialize(): self = xp.AbstractContactSelector(args);
Save up to 630$ when buy new iPhone 15
Free Airdrops to Claim, Share Up to $150,000 per Project
Open tool hub for free to use by any one for every one with hundreds of tools,,,
Talk to ChatGPT by your mother language
Generate creative images automatically with AI
Render creative video automatically with AI

JavaScript by day

Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web