如何查看内置JavaScript函数的来源? [英] How can I see the source of built-in JavaScript functions?

查看:48
本文介绍了如何查看内置JavaScript函数的来源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,alert(),Object(),String()等.我如何看待这些函数背后的代码?

E.g., alert(), Object(), String(), etc. How would I see the code behind these functions?

我需要了解引擎的语言,例如 V8 ,是通过这种方式编写并阅读的,还是有一个更简单的解决方案?

Would I need to understand the language that an engine, such as V8, is written in and read through that, or is there a simpler solution?

推荐答案

我怎么看这些功能背后的代码?

How would I see the code behind these functions?

您需要找到相关项目的源代码(Firefox,Chromium,V8,SpiderMonkey等),前提是该项目是开源的.

You would need to find the source code for the relevant project (Firefox, Chromium, V8, SpiderMonkey, etc.), provided the project is open-source.

我是否需要了解编写和阅读V8之类的引擎的语言,或者有没有更简单的解决方案.

Would I need to understand the language that an engine such as V8 is written in and read through that, or is there a simpler solution.

是的,你会的.请注意, alert 不是JavaScript函数,而是由Web浏览器定义的函数(因此,您需要查看Firefox或Chromium等源代码). Object String 都是JavaScript的一部分,因此您需要查看这些JavaScript引擎的源代码(SpiderMonkey [或任何 Monkey,前缀似乎有很大的变化]和V8等.

Yes, you would. Note that alert is not a JavaScript function, it's a function defined by web browsers (so you'd need to look at the Firefox or Chromium, etc., source). Object and String are both part of JavaScript, so you'd look at the JavaScript engine sources for those (SpiderMonkey [or whateverMonkey, the prefix seems to change a lot] and V8, etc.).

这篇关于如何查看内置JavaScript函数的来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆