0

Trying to understand how JS works in particular window.Math.random().

I check already by console

this

and prints out all the content, right! but on Math.random you can not continue. Always the same message.

"function random() {
    [native code]
}"

So reading I saw a method call .toSource() by Mozilla(because is the only one supported by). So and this is the result so far.

"function random() {
    [native code]
}"

I check already that this is because of C or C++, that are "Native Code"

So it's possible to get to know the method random() works?

Even do just to se how actually js work...

Also just for fun I tried to get the source from .toSoruce()

Object.prototype.toSource.toSource()

Try it just for fun. (use Firefox)

  • Sure! Just download Firefox sources and find where this method gets defined. I have a [similar question](https://stackoverflow.com/questions/33268638), i think it may be helpful for you – lucifer63 Aug 25 '19 at 17:20

1 Answers1

0

I don't think there really should be some explanations, just take a look at https://hg.mozilla.org/mozilla-central/file/default/js/src/jsmath.cpp#l919

You can read about their directory structure here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Directory_structure

Here you can take a look at the actual file structure of mozilla-central: https://hg.mozilla.org/mozilla-central/file/default/. Press zip, gz or bz2 at the top to download currently selected directory.

lucifer63
  • 784
  • 9
  • 32