Why use the `var` keyword in Vue.js?
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...
- Feel comfortable using, and
- Is supported by the target production environment
- your build system (if you're using one) can help transpile ES6 code to a lower language level
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.