Is declaring helper variables which are simply removal of `this` bad practice?
hayashi-ay
Posted on March 29, 2020
Hi there, I'm newbie for dev.to and this is my first post.
Our company has a convention to declare helper variables which are simply removal of this
like the following.
export class SampleClass {
constructor() {
// this is a constructor
}
get sampleGetter() {
// return something
}
sampleMethod() {
// What do you think about the following?
const sampleGetter = this.sampleGetter;
// do something
}
}
I was thinking that it's efficient when the variables are used multiple times.
However, I've been recently pointed out that it's premature optimaization and just adds a tiny bit of complexity with no clarity.
What do you think? I'd like to hear your opnions.
💖 💪 🙅 🚩
hayashi-ay
Posted on March 29, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
discuss Is declaring helper variables which are simply removal of `this` bad practice?
March 29, 2020