admin管理员组

文章数量:1178553

I have written a bunch of Javascript code. I was never aware of the fact that there are multiple JS 'versions', like ES5 and ES6.

I now have this project hosted on Github, and somebody pointed out that because i'm using ES6 code, I might need to convert it to ES5 with Babel.

However, I have no idea which parts of my code use ES6. I could read all of the ES6 specifications, but is there some kind of tool/checker which marks all of the ES6 code in my project?

I have written a bunch of Javascript code. I was never aware of the fact that there are multiple JS 'versions', like ES5 and ES6.

I now have this project hosted on Github, and somebody pointed out that because i'm using ES6 code, I might need to convert it to ES5 with Babel.

However, I have no idea which parts of my code use ES6. I could read all of the ES6 specifications, but is there some kind of tool/checker which marks all of the ES6 code in my project?

Share Improve this question asked Jul 28, 2017 at 15:51 Thomas WagenaarThomas Wagenaar 6,7496 gold badges34 silver badges84 bronze badges 6
  • 1 eslint for example. – alexmac Commented Jul 28, 2017 at 15:52
  • Well if it works as is in your current environment, no you don't need Babel. If you used some feature that's not supported, you would know. – Bergi Commented Jul 28, 2017 at 16:02
  • @Bergi I host this project on Github, so others with possibly different browsers/runtimes run it as well – Thomas Wagenaar Commented Jul 28, 2017 at 16:03
  • @ThomasW Well then they should be able to transpile it for their needs. Or do you host production files (transpiled and minified) and guarantee support for certain environments? – Bergi Commented Jul 28, 2017 at 16:07
  • @Bergi dude your missing the entire point, if someone is making a project with the hopes that it be publicly available, its expected that it should just work on others computers. Even though this is a github project and not a website, but the same ideas or a website would appy, you wouldnt want to average user having to compile the entire webpage with babel before just going on to it to have it work – B''H Bi'ezras -- Boruch Hashem Commented Jun 15, 2020 at 1:19
 |  Show 1 more comment

2 Answers 2

Reset to default 21

http://jshint.com/ or http://www.jslint.com/ - will detect ES6 specific specifications by just adding your code in the console

Add it into the Babel repl and see if it changes:

https://babeljs.io/repl/

:-) Hope that helps

Other than that it might be best to setup es6 with babel using webpack, gulp, rollup etc

So that if you write es6 or es5 it will automatically get converted and you can learn some new features on the way while still supporting es5 only browsers

本文标签: javascriptHow to check if you have written ES6 codeStack Overflow