Kmils21
4.05.2015, 10:44:47
Witam mam np taki kod
var test = function(){
this.a = 10;
this.b = 20;
this.suma = function(){
return this.a + this.b;
}
}
jak w tym zrobić metodę statyczną, tak żeby mógł się do nie odwołać przez zmienna "test"? Proszę o pomoc, w JS jest tyle sposobów programowania obiektowego że nie mam pojęcia po jakim hasłem tego szukać.
Kmils21
4.05.2015, 12:03:55
np chce cos takiego
teraz robę tak:
var test = function(){
this.a = 10;
this.b = 20;
this.suma = function(){
return this.a + this.b;
}
this.jakastamfunkcja = function(){
return -1;
}
}
var objekt = new test();
objekt.a = 100;
objekt.suma();
a chce np
test.jakastamfunkcja();
nospor
4.05.2015, 12:08:33
Kod
function Klasa(){};
Klasa.jakasfunkcja = function(){
alert('Blabla');
}
Klasa.jakasfunkcja();