// code 1
var pacientes = document.querySelectorAll(".paciente");
for(var i = 0; i < pacientes.length; i++){
var paciente = pacientes[i]; //linha desnecessária
paciente.classList.remove("invisivel");
}
// Code 2
var pacientes = document.querySelectorAll(".paciente");
for(var i = 0; i < pacientes.length; i++){
pacientes[i].classList.remove("invisivel");
}
Above you have two different code snippets, get a code in JS where I saw that this practice was common across several snippets of code, declaring a variable receiving the array element var paciente = pacientes[i];
, however I think it's much more practical to put the array element in its position and remove it from the class: pacientes[i].classList.remove("invisivel");
, as we see in the second code.
As the code was well structured I was in doubt if this would be a good practice (if yes, why? because I can not see good practice in this), or would be just to leave the code more didactic.