Where can I find javascript native functions sourc

2019-01-09 13:33发布

问题:

This question already has an answer here:

  • How to see the source of Built-in javascript functions? [closed] 1 answer

where can I find the source code of native js functions, for example I want to look at eval() function

回答1:

In the JavaScript engine's source code.



回答2:

Both Chrome and Firefox are open source and you can look at the implementation of any part of the javascript engine in the source code for those products. Other browsers have their own implementation (like IE) that is not available to the public to look at.

The Chrome v8 javascript engine is here: http://code.google.com/p/v8/

The Firefox SpiderMonkey engine is here: https://developer.mozilla.org/en/SpiderMonkey

Warning, if you aren't already familiar with those products and their tools, it may take while to get familiar enough to find what you're looking for.



回答3:

Javascript is a script language that is implemented within a Browser's code-base. This means that there may be different implementations of the script language, with different levels of quality, and possibly different intepretations of what is required. Hence the head-against-wall frustrations of many a web-developer when dealing with different web-browsers.

It is possible for you to examine a browser's implementation of Javascript if the browser is an Open Source version, eg: Chrome, Firefox, as given in other answers listed.