Thursday, March 22, 2012

Javascript Object oriented programming

I forget the style of JS class.

Define class object
//Define class 
function Class1(val1, val2){
  //Define propaties
  this.val1 = val1;
  this.val2 = val2;
}


Define method
Class1.prototype.getVal1 = function getVal1_Class1(){
  return this.val1;
}

Create class instance

var instance1 = Class1(10,20);

No comments:

Post a Comment