Prototypes in JS 2

about prototype in JS

by Samar Pattanayak

JavaScript

//Object.prototype.bar="Samar Patt";
var parent = function(name, place) {
  this.name = name;
  this.place = place;
  this.convey = function() {
    alert("Hi my name is " + this.name + " and i stay at " + this.place);
  }
}
var ObjParent = new parent("Samar", "BBSr");
ObjParent.convey();

var child = function() {
  parent.call(this, "Varun", "Madras");

};
//child.prototype= new parent("Varun", "Madras");
child.prototype.constructer = child;
child.prototype.sayHi = function() {
  alert("Hi i am from child prototype method");
}

var ObjChild = new child();
ObjChild.convey();
ObjChild.sayHi();