[javascript] Assign variable in if condition statement, good practice or not?