Pierwszy sposób:
Kod
Object =
{
Version: '1.0',
setVersion: function (Version)
{
this.Version = Version;
},
getVersion: function ()
{
return this.Version;
}
}
{
Version: '1.0',
setVersion: function (Version)
{
this.Version = Version;
},
getVersion: function ()
{
return this.Version;
}
}
Oraz drugi sposób:
Kod
var Object = function ()
{
this.Version = '1.0';
this.setVersion = function (Version)
{
this.Version = Version;
}
this.getVersion = function ()
{
return this.Version;
}
}
{
this.Version = '1.0';
this.setVersion = function (Version)
{
this.Version = Version;
}
this.getVersion = function ()
{
return this.Version;
}
}
Jaki są zalety, jak i wady korzystania z danego rozwiązania? Kolejne pytanie, czym jest this[0] w JavaScript?