-4

For example, i want to know how the querySelector method was built. I checked on MDN but there's only examples that show how to use it.

I also tried to check in the console.log but nothing readable.

0

1 Answer 1

0

There is a non-standard method to do this. Please be aware that it is not fully cross-browser compatible and shouldn't be used in a production environment.

function hello(){
    return "Hi!";
}
console.log(hello.toSource());

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource for more.

Edit: To see the source code of a built-in function, you will need to look at the engine source. This varies browser to browser. For example, Chrome uses the V8 engine. See https://github.com/v8/v8

Sign up to request clarification or add additional context in comments.

2 Comments

I think the OP wants to see the source code of native javascript functions.
... which just shows up as function() { [native code] }.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.