Question

Possible Duplicate:
How does a JavaScript parser work?

How do browsers compile Javascript scripts? What type of compiler it used?

Was it helpful?

Solution

JavaScript isn't compiled, but rather parsed and interpreted. This differs from browser to browser.

Chrome, uses V8, which happens to also be used by node.js. Internet Explorer has a proprietary engine known as Chakra.

As for general rules, the Annotated ES5 shares some insight:

The source text of an ECMAScript program is first converted into a sequence of input elements, which are tokens, line terminators, comments, or white space. The source text is scanned from left to right, repeatedly taking the longest possible sequence of characters as the next input element.

OTHER TIPS

The browsers don't compile javascript, it just parse the file and execute it.

Look here: JavaScript_engine

Javascript gets interpreted; this is like compiled on the fly, while running, when needed. That's why a page with javascript errors will just work until a part of bad code gets used. the bad code block will just stop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top