Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRicardo Sala
16,212 PointsHow can I make JavaScript be as strict a Java? (types declaration, requiring "let" before declaration...)
hey!
I am a begginer java developer and I want to take a look at JS too.
However, I really like Java strictness (I think it really helps to find errors).
I just heard that there is a way to make JavaScript more strict (like asking for data types, making compulsory the use of "let" before variables declaration and so for).
Do you know what is that?
Currently I use IntelliJ IDEa, and it is really cool, but being JS so ...flexible, I don't think I can find a compiler that is so good helping you to write code...
Do you know any?
THANKS!!!!!!
2 Answers
Ari Misha
19,323 PointsHiya there! I dunno much about Java but i know enough to answer your question. Many people would say that JavaScript has nothing to do with Java but JavaScript is changin' and the new syntaxes for OO for JavaScript pretty much looks and feels like java except for implementing data types with every variables. Both languages have their own version of "strict" mode. In order to operate in strict mode , you've to declare use strict; in the beginning of script. This type of style of writing JS codes is not so popular 'coz its only there in JavaScript for a sole reason i.e., compatibility with older version of JavaScript. Also it lets you write secure JavaScript code.
Now regarding Text Editors, I actually use 4 text editors from Jetbrains (RubyMine, WebStorm, IntelliJ, PyCharm). And all of 'em feels kinda same to me. They are great for professional and big projects but not for learning. Sometimes i like ligh weight IDE like Sublime Text 3. Webstorm is as great as IntelliJ and so are RubyMine ad PyCharm. But you can achieve everything else with your command line. I want to do everything with my terminal , thats the only thing im comfy with.
JavaScript is not a compiled language but there are tools that are emerging nowadays which compiles JS for faster performance and minifying of files and they also transpiles in native/document JavaScript. Exactly like TypeScript or Babel or Webpacks or Gulp or Grunt. I hope i've answered your questions.
~ Ari
Alexander La Bianca
15,959 PointsES 6 is trying to help developers be more OO with Javascript even though it is all syntactical sugar. I suggest looking into TypeScript.