Every tutorial and code snippet I'm looking at while learning the framework all use var
for their declarations, including the official docs.
Preface, I'm just starting to learn Vue, so I know very little about it, but haven't found an answer yet.
Same with other like assuming property name:
new Vue({
data: data
})
vs.
new Vue({
data
})
Am I wrong in assuming that ES6's const
and let
should be standard? Is there a reason to use var
for Vue.js? Is there an issue with ES6?
Why do the docs use var
and avoid ES6 features? I'd say to support lowest common denominator, ie, worst browser.
Since Vue can be included as a plain old <script>
tag (UMD / global, no build system) and supports all ES5-compliant browsers (IE9+), they keep the documentation consistent.
Use whatever you...
Besides the lowest common denominator arguments I would like to point that var
and let
have different semantics.
When using var
variables are function scoped and they get hoisted. When using let
they are blocked scoped and they don't get hoisted.
So even if let
and const
are standard they (probably) won't replace var
any time soon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With