1

How can I see how native js functions are implemented in a browser?

I've tried Math.floor.toString() but it returns "function floor() { [native code] }" and I can't step into the function using debugger.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488

2 Answers2

6

You can't do this from the console, because the functions are part of the compiled browser executable … or, rather, its JavaScript engine. It is native code.

You may be able to read the source code for that engine, though, depending on which browser you're using. For example, Chrome's v8 source is on GitHub.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
-3

Updated

It's a native function. I'm guessing you could download the source code for a browser, as that's where it's implemented

Firefox Source code for example

overburn
  • 1,194
  • 9
  • 27