1. Javascript constructors are syntactically same as functions.
2. Javascript constructors are used for grouping related variables and functions.
3. Use Pascal casing rules for naming Constructors (Ex: DoctorDetails instead of doctorDetails i.e use uppercase letter on every first character of a word).

Following sample creating a doctor constructor with name, age, experience fields along with the actions associated with doctors.

Note: Constructors in Javascript serves similar purpose as classes and structures in java, C# other object oriented programming languages. Following sample code creating Doctor Constructor, in the Doctor constructor this.Name will create a Name variable and makes it as part of Doctor, same way Age and Exp variables are also created as part of Doctor Object.

getMedicineForDisease becomes a variable which is holding suggestMedicine methods. By using Doctor Object variable if getMedicineForDisease is called, the call will be internally handed over to suggestMedicine method.
<script language="javascript" type="text/javascript">

function Doctor(name,age,exp) {
 this.Name=name;
 this.Age=age;
 this.Exp=exp;
 this.getMedicineForDisease=suggestMedicine;
}

function suggestMedicine(disease) {
 if (disease=='fever')
   return 'paracetmol';
 else if (disease=='malayria')
   return 'xyz medicine';
 else
   return 'abc medicine';
}

function fnTest() {
var oDoctor=new Doctor('dr.rajeev',29,4);
oDoctor.getMedicineForDisease('fever');
alert(oDoctor.Age);
alert(oDoctor.Name);
}
</script>