where can I find the source code of native js functions, for example I want to look at eval()
function
In the JavaScript engine's source code.
eval
function defined?". And "tell us something we don't already know"? This is not an answer for you or the people who already know, it's for the ones who don't. –
Adherent console.log(Date)
and you'll most likely see function Date() { [native code] }
. –
Adherent 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 code is here: https://github.com/v8/v8
The Firefox SpiderMonkey engine code is here: https://searchfox.org/mozilla-central/source/js/src
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.
These links may change over time, but can easily be found with Google searches if they move.
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.
In the JavaScript engine's source code.
eval
function defined?". And "tell us something we don't already know"? This is not an answer for you or the people who already know, it's for the ones who don't. –
Adherent console.log(Date)
and you'll most likely see function Date() { [native code] }
. –
Adherent © 2022 - 2024 — McMap. All rights reserved.
eval
in particular is the whole engine (or at least, it's an entry point to the whole engine). There are lots of Javascript engines out there to look at. – Electrotype