A look into Getters and Setters in JavaScript

1 · Amit Merchant · Aug. 8, 2019, 2:18 p.m.
There are always multiple ways of doing things. Programming is no different. For instance, in JavaScript, what would you do if you want to get the property of an object running some operation before returning it? Take this example. var person = { firstName: 'Amit', lastName: 'Merchant', fullName: function() { return this.firstName + ' ' + this.lastName; } } console.log(person.fullName()); // Amit Merchant As you can see, in order to get the fullname which is concaten...