1 hour ago · Tech · hide · 0 comments

Reflection is an important tool in programming; it lets us examine a language’s structure. Can we reflect in JavaScript? Sort of. Some functions can be reflected with toString(): > const one = () => 1 undefined > one.toString() '() => 1' Very cool! But native functions only return this: > Math.max.toString() 'function max() { [native code] }' You must read the ECMA Script specification to know what the function is required to do. The actual implementation is written in the JavaScript engine, likely in another language like C++, which is why Node can’t show it via toString().

No comments yet. Log in to reply on the Fediverse. Comments will appear here.