Reputation: 840
In console it appears as native function but I'd like to know how they were constructed. For example what is the code which executes when pressing space bar to scroll the page. That info would teach me a lot, and I could make my functions more effective
Upvotes: 33
Views: 23442
Reputation: 11382
The contract for exactly how the Javascript built-ins should behave is outlined in the ECMAScript specification (see example for Array.every()
).
There are a number of different Javascript engines, each with their own specific implementation of ECMAScript. The most common Javascript engines are (links point to code for Array.every()
):
Upvotes: 2
Reputation: 943571
Some repositories include:
Note that JavaScript native functions are generally not written in JavaScript (expect C or C++ most of the time). They are just exposed to JS through an API.
Also note that the code that scrolls a page when the spacebar is pressed isn't even a function that is exposed to JS.
Upvotes: 21
Reputation: 9042
What is V8?
Upvotes: 3
Reputation: 4057
While this will not show you actual source code, if you're interested in how many of the native JavaScript functions are implemented, you can peruse the specification upon which they are based:
Upvotes: 15