Skip to content

Commit

Permalink
q3 removed unnessesary code
Browse files Browse the repository at this point in the history
  • Loading branch information
ganqqwerty committed Aug 14, 2018
1 parent df81a19 commit 3e1c282
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,13 @@ var Employee = function (name, company, salary) {
this.company = company || "";
this.salary = salary || 5000;

// Private method
// We can create a private method like this
var increaseSalary = function () {
this.salary = this.salary + 1000;
};

};

// adding the method to Employee's prototype
Employee.prototype.displayIncreasedSalary = function() {
increaseSalary();
console.log(this.salary);
};

// Creating three Employee objects
var emp1 = new Employee("John", "Pluto", 3000);
var emp2 = new Employee("Merry", "Pluto", 2000);
var emp3 = new Employee("Ren", "Pluto", 2500);
```

Here each instance variable `emp1`, `emp2`, `emp3` has own copy of increaseSalary private method. However the `displayIncreasedSalary` will only be added once to an object `Employee.prototype`.
Expand Down

0 comments on commit 3e1c282

Please sign in to comment.