Skip to content
Related Articles

Related Articles

What are .extend and .prototype used for?

View Discussion
Improve Article
Save Article
  • Last Updated : 30 Jun, 2020


The JavaScript / jQuery extend method copies all properties from the source to the destination object. The primary use of the extend method is in class declarations with the purpose of creating a class (sub-class) that is the child of another parent class (super-class). It can be used to subclass both the built-in objects as well as the user-defined (custom) classes.


class child_class extends parent_class { 
    // class definition goes here



// Parent Class
class Animal {
  constructor(name) { = name;
// Child Class
class Dog extends Animal {
  constructor(name) {
    // the super keyword to used to call 
    // the constructor of the parent class
    super(name); = name;


The prototype property is a unique feature of the JavaScript language. The prototype property acts as a member of objects. Its primary use is to allow the addition of new properties (members or functions) to object constructors. It is also used to inherit features from one to another. The need for prototyping arises because JavaScript does not allow addition of new property to an existing object constructor.

Syntax: = value;

// For class members:
ClassName.prototype.member_name = member_value; 

// For class methods:
ClassName.prototype.function_name = function() {
    // function definition



class Employee {
    let firstName;
     let lastName;
    // constructor
    Employee (first, last) {
        this.firstName = first;
        this.lastName = last;
// add class data member = "";
// add class member function
Employee.prototype.fullName = function() {
      return this.firstName + " " + this.lastName;

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!