Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read ‘native code’ JavaScript functions?

Tags:

javascript

Is there any way to see the declaration of JavaScript native code? Whenever I try to look at a native function in Chrome or Firefox, it says "native code":

> String.fromCharCode function fromCharCode() { [native code] } 

What does this mean, and is there any tool which can help me to read actual code?

like image 548
emphaticsunshine Avatar asked Feb 01 '12 21:02

emphaticsunshine


People also ask

What is a native function JavaScript?

The native prototype is a JavaScript property that all built-in constructor functions in JavaScript use to inherit methods and properties from one another.


2 Answers

The reason Chrome or Firefox says that the code is native is that it really is native - the WebKit and Firefox developers have coded up that functionality in C or C++, not JavaScript. However, if you want to see the actual code, you can look at the source repositories for Chromium and Firefox.

like image 134
Adam Mihalcin Avatar answered Sep 28 '22 07:09

Adam Mihalcin


Not within the JavaScript environment, but you can view the source for the open-source implementations.

Google V8: http://code.google.com/p/v8/source/browse

Mozilla SpiderMonkey: https://developer.mozilla.org/en/SpiderMonkey

like image 20
user1106925 Avatar answered Sep 28 '22 07:09

user1106925