-3

I have an employer object

{Name: "",
Salary: 1000,
Department: "",
};

can I sum two of these objects asObject1 + Object2 and as result get the sum of their salaries.

In Python with classes this is done like this:

def __add__(other):
    return self.salary + other.salary 
Bot Ellis
  • 20
  • 3

0 Answers0