Javascript Getter and Setter
Mahin Tazuar
Posted on December 23, 2021
Today i am talking about javascript getter and getter.
Js Setter and getter using for highly manupulate javascript object value. We can calculate js object value using this two things.
class Thermostat {
constructor(fahrenheit) {
this.fahrenheit = fahrenheit;
}
get temperature() {
return (5 / 9) * (this.fahrenheit - 32);
}
set temperature(celsius) {
this.fahrenheit = (celsius * 9.0) / 5 + 32;
}
}
💖 💪 🙅 🚩
Mahin Tazuar
Posted on December 23, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.