I'd like to know if the first or the second way are more efficient and I am also asking about similar situations because they come up pretty often. It's all frontend code (React). I'd really like to know. Thanks!
(input) => {
setState(parseInt(input, 10))
updateAuction(parseInt(input, 10))
...
Or, saving the result of parseInt into a var and using the var
(input) => {
const parsedInput = parseInt(input, 10)
setState(parsedInput)
updateAuction(parsedInput)
...
This and similar situations bother me every day, because I don't know the answer. I also have string comparisons quite often.
logoVariant === "small" && do something
logoVariant === "small" && do something else
or
const isLogoSmall = logoVariant === "small"
isLogoSmall && do something
isLogoSmall && do something else
Thanks!