admin管理员组文章数量:1426007
Is there a way to see the code behind a JavaScript's method? Not a javascript method from the website's .html or .js files, but JavaScript's internal methods.
For example:
- How can I see how JavaScript calculates the
offsetTop
of an element?
Is there a way to see the code behind a JavaScript's method? Not a javascript method from the website's .html or .js files, but JavaScript's internal methods.
For example:
- How can I see how JavaScript calculates the
offsetTop
of an element?
- 1 It's browser dependent. Also some browsers might not even use JavaScript for its internal calculations. – Dave Chen Commented Apr 16, 2016 at 0:08
- For example of I want to see with chrome? – Fistright Commented Apr 16, 2016 at 0:11
- See also How to see the source of Built-in javascript functions? – Bergi Commented May 23, 2017 at 10:08
1 Answer
Reset to default 6JavaScript is implemented by the browser, so it depends on the browser.
Google's browser, Chrome
, is closed-source not open-source. Which means that you can't view their source code, including their implementation of JavaScript. But, Chrome's source code is based on Chromium's source code, which is open source. You can view all of its source code in its git repository here. See more about this Chrome-Chromium relationship at the bottom of my answer.
Mozilla's browser, Firefox
, is open-source just like all of their projects. You can view all of the source code for Mozilla projects here. You'll find the code that implements JavaScript in Firefox right here.
For closed-source implementations of JavaScript, like Chrome's, you can never be sure exactly how each method works. By reading the documentation available (see below), you will be able to get the best available idea of how a method might be implemented.
Note that just because Chrome's source code is based off of the open source project, Chromium, that doesn't mean the source code is the same. Chrome could have made tweaks to to JavaScript methods, and we wouldn't know. I think that is unlikely though, and all of the differences between Chrome and Chromium are most likely listed on this wikipedia page, and a nice post is available here on AskUbuntu
You can learn a lot more about Chromium's source code here.
Chrome JS documentation
本文标签: Source code of implementation JavaScript internal methodsStack Overflow
版权声明:本文标题:Source code of implementation JavaScript internal methods - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745360683a2655278.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论