程序代写代做代考 Java javascript # Semantic differences between original ES6 and transpiled ES3
# Semantic differences between original ES6 and transpiled ES3
### Referenced (inside closure) before declaration
`defs.js` detects the vast majority of cases where a variable is referenced prior to
its declaration. The one case it cannot detect is the following:
“`javascript
function printx() { console.log(x); }
printx(); // illegal
let x = 1;
printx(); // legal
“`
The first call to `printx` is not legal because `x` hasn’t been initialized at that point
of *time*, which is impossible to catch reliably with statical analysis.
`v8 –harmony` will detect and error on this via run-time checking. `defs.js` will
happily transpile this example (`let` => `var` and that’s it), and the transpiled code
will print `undefined` on the first call to `printx`. This difference should be a very
minor problem in practice.