should we declare var in side $.each or loops or immedialy above them

should we declare var in side $.each or loops or immedialy above them

hi,

    I heard that variables must be declared above the loop to avoid the declaration cost specially in sql server.
so here in jquery i noticed people declaring variables in side the loop lik e$.each or foreach loops .

q1) is it good practice?

yours sincerely