O
O
Ostap2020-08-07 23:32:34
JavaScript
Ostap, 2020-08-07 23:32:34

js function or variable?

Hi all.
which is preferable to a function or a variable, I am writing a react component, where the value should be displayed in the markup.
it can be evaluated as a function and called in markup
like

const getQuantity = () => {
        return products.length
    }

or as a variable
for example
const quantity = products.length

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Somewhere Intech, 2020-08-07
@john36allTa

Damn question... Sorry! Is the length property the same for products? If yes, then it is const

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question