There are some questions about babel conversion for beginners of es6.

originally run directly in the browser (Chrome 65) will report ReferenceError errors, but after babel conversion, and then run, it will be undefined, these two errors are completely different, does it mean that the conversion of babel is not complete?

clipboard.png

clipboard.png

Feb.26,2021

the variable names are all different after conversion, one is tmp, and the other is _ tmp. And is defined by var, variable promotion, print _ tmp is undefined


babel ability is limited, can not make the converted ES5 code has block-level scope. So the solution here is to replace the variable with the same name with a variable with a different name, which has the same effect


because it gives priority to the conversion of let (which is why most of the time you have to be strict with the code (such as using 'use strict'), you can't assign a value before declaring it. ), causing the tmp in the if block to be actually a new variable, and relative to the es6 error, es5 will not report an error for something that is not declared, but will only say that it undefined


excuse me, but just posted the converted code incorrectly. Now corrected

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c5db-2bb07.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c5db-2bb07.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?