Basically I was looking for how 'new' and 'prototype' things works out in Java script, and I could find very good site, which has lot of stuff on these areas.
http://ejohn.org/apps/learn/#65
Example #1:
RecordManager= function(){};
RecordManager.prototype.getRecords = function(){
return true;
};
var manager = new RecordManager();
assert(manager.getRecords(), "status");
Output: PASS status
Example #2:
function RecordManager(){}
RecordManager.prototype.addRecords= function(){
return true;
};
var manager1 = RecordManager();
assert( manager1 , "Is undefined, not an instance of RecordManager." );
var manager2= new RecordManager();
assert( manager2.addRecords(), "Method exists and is callable." );
Output:
- FAIL Is undefined, not an instance of RecordManager.
- PASS Method exists and is callable.