SoFunction
Updated on 2025-03-01

Javascript constructor, public, private privilege and static member definition methods


//Constructor
function myClass(message)
{
//Public attributes
= message;

//Private Attributes
var _separator = ' -';
var _myOwner = this;

//Private method
function showMessage()
{
alert(_myOwner.myMessage);
}

//Private method (also a public method)
= function(appendMessage)
{
+= _separator + appendMessage;
showMessage();
}
}
//Public Method
= function()
{
= '';
}
= {
clearMessage:function(){
= '';
}
}
// Static properties
= 'SOBusiness';
// Static method
= function()
{
alert();
}