0

How can I open the underlying script of built-in functions like Array.prototype.map. I'm just really curious about what is inside. I tried to dig deep in the console but did't find anything. Constructor node doesn't have any content inside.

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
Max Lyoto
  • 27
  • 4
  • 2
    It shows `{ [native code] }` because it's native code. You can look at the source code of v8 or spidermonkey or another js engine, but the code isn't implemented in js. It depends on the engine, but i think v8 is C++ – Samathingamajig Jul 29 '22 at 21:36
  • 1
    It's probably some native code implementation. You can see the algorithm in the spec. Good reading. https://262.ecma-international.org/13.0/#sec-array.prototype.map – IT goldman Jul 29 '22 at 21:38

1 Answers1

1

If you try to run javascript code in the Chrome console or Node.js console the code will be executed at the top of the v8 engine.

And to see the source code of built-in functions and methods go to the public repo of v8 because it's open source : https://github.com/v8/v8

on this page, if you ctrl + F "map" to search trough the page you will see the files where the map method is written !

Wawa
  • 273
  • 2
  • 11