+ 3

Assigning variables for no reason

So, I have been debugging some javascript code lately and the programmers experience might vary. What bothers me, is that they so often assign variables for values that are already for example class properties. To me it just seems counter-productive for the over-all performance. Does someone have any insights for this sort of programming, that I'm missing? I don't know whether to complain to them or thank them.

7th Oct 2017, 11:20 PM
eRosz - avatar
3 Answers
+ 5
Usually, the only instances where I feel I should create a variable to store a value assigned to a class/object property is when it will a.) increase readability, b.) increase production rate, or c.) increase performance (rare in JS). Sounds like you should at least bring it up with the developer and see if they have any good reason(s) for doing this.
7th Oct 2017, 11:59 PM
Shane Overby
Shane Overby - avatar
+ 4
@Shane Okay, thanks for the in-depth answer. I have gone through the code as in-depth as I can, and only viable choice of those provided turns out to be the increased readability. Javascript is not really officially a part of my expertise but has turned out to be pretty essential for the current project. Had to double-check that there aren't any JS insider traits that support the conduct. Readability is not that important for the project, especially if it compromises the potential of the performance.
8th Oct 2017, 1:59 AM
eRosz - avatar
+ 1
can you elaborate it please, I didn't get your actual question
7th Oct 2017, 11:27 PM
Nura Programmer
Nura Programmer - avatar