0

Reading some vuejs 3 with Composition API docs I see 2 possible way of vars declaring, like

const var_name = ref('')

or

let var_name = ref('')

and looks like var declared with “const” can be modified(say getting data with axios request). I do not see any errors when I use similar code inb my app.

Are these declarations the same? Which way is preferable?

1 Answer 1

2

I think an article like this is still the best way to go here: https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/

As of what is recommended, usually use const and if you need to redefine something else on top of it, use let. Of course, non primitive types (like Objects) can be mutated, it being out of the const scope redefinition.

TLDR: this is more of a JS vanilla question and have nothing to do with Vue or Composition API in particular.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.