Already heard about Object Oriented Programming on Javscript, well !, now post it in here cos i think this very important, specially people who will concern about AJAX scripting. However know about OOP on Javascript will make you better on Javascript programing.
This is a very simple sample, how to write:
<script language="Javascript">
ProgKu={
pariabelsatu : "Javascript" ,
parkedua : "" ,
fungsiSatu :
function(val){
if ( ( (val * 5) % 2 ) == 0 ) {
this.pariabelsatu = "Javascript hasil OOPJs";
this.parkedua = "Genap" ;
return true;
}else{
this.pariabelsatu = "Hasil gak bener";
this.parkedua = "Ganjil" ;
return true;
}
}
fungsiDua :
function(){
var t = prompt("Masukan angka 1 hingga 1000");
var myVal = parseInt(t);
if(isNaN(myVal)){
alert("Yang dimasukan bukan angka");
return false;
}else{
this.fungsiSatu(myVal);
}
}
}
//Sudah diluar class
function cobaCoba(){
var h = ProgKu.fungsiDua();
document.getElementById("test").innerHTML =
h.pariabelsatu +" mungkin karena "+h.parkedua;
}
And on HTML please put this code :
<div id="test">Look at here</div>
OK, have nice try :p


