//Constructor
function myClass(message)
{
//Public properties
this.myMessage = message;
//Private properties
var _separator = ' -';
var _myOwner = this;
//Private method
function showMessage()
{
alert(_myOwner.myMessage);
}
//Privileged method (also public method)
this. appendToMessage = function(appendMessage)
{
this.myMessage = _separator appendMessage;
showMessage();
}
}
//Public method
myClass.prototype.clearMessage = function()
{
this.myMessage = '';
}
myClass.prototype = {
clearMessage:function(){
this.myMessage = '';
}
}
//Static property
myClass.myName = 'SOBusiness';
//Static method
myClass.alertName = function()
{
alert (this.name);
}
Note: There are two methods used in the public method declaration part. In actual applications, one method is generally used. If there are two methods If both are used, attention should be paid to the order to prevent previously written methods from being cleared or overwritten.