Chalarangelo/30-seconds-of-code

Terminology issue in blog

kamtoeddy opened this issue · 4 comments

Hi maintainers,

Going through the interview prep. resource on variable hoisting, I noticed that the first sentence of the first paragraph had an issue.

It goes "Before your JavaScript code is executed, it is first parsed and compiled". My problem here is compiled. JavaScript is an interpreted language.

Thanks

It might be a little confusing, but technically it's true as JavaScript engines use a JIT (just in time) compiler to execute the code. If you can suggest a less confusing explanation that won't complicate things for beginners, feel free to comment down below as it might be worthwhile.

Awesome

Your response is spot-on. We could say something like "Before your JavaScript code is executed, it is first parsed and compiled(just-in-time compilation)".

I think putting JIT there and a link to a resource that will provide more clarity on what JIT is all about. This could even be a small(yet detailed enough) paragraph at the end of the article if you like

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution by the parser which reads the source code into an intermediate representation before the actual execution starts by the JavaScript interpreter.

Before any execution, and before interpreting the code, hoisting is done during the parsing phase.

Moreover, for the one who want to make a pull request, you might add that hoisting is done only in non-strict mode, and can be avoided by using "use strict" at the beginning of the file.

You can reference for "use strict" from a previous code snippet.