XMPP JavaScript Library

How to use OOPs in JavaScript

JavaScript, Sachin Puri, 2012-04-07 13:32:19


This tutorial will give you an example of using OOPs concets in JavaScript. There are many other ways of implementing OOPs in JavaScript but i like this approach most.

        function employee(emp_id,emp_name)
            //Class variables

        //Class Member Functions
            alert("Employee ID: " + this.employee_id + " Employee Name: " + this.employee_name);

        //Create First Object
        emp1=new employee(1,"Sachin"); //Create object of class        
        emp1.getDetails(); //Call member function of class

        //Create Second Object
        emp2=new employee(2,"Abhinav"); //Create object of class        
        emp2.getDetails(); //Call member function of class


Add Your Comment
    Yes! I want to receive all comments by email

  by Dorothy on 07-Mar-2019 11:50 pm
This tutorial will teach the people who would like to use this code in javascript.This australianwritings isa great example for implementing this code in the javascript.There are many ways to learn and implementation in the right direction.
  • Reply
  •  0 Like
  •  0 Dislike
  • Report