JavaScript: Function.prototype.toString

By Xah Lee. Date: . Last updated: .
f.toString( )
Return a string representation of the function f. The returned result may not be exactly the same between browsers or other JavaScript implementation.
function f () { return 3; }
console.log( f.toString () === "function f () { return 3; }" ); // true
const ff = (x => 3);
console.log( ff.toString () === "x => 3" ); // true
console.log( Array.toString () === "function Array() { [native code] }");
console.log( Function.toString () === "function Function() { [native code] }");
console.log( Object.toString () === "function Object() { [native code] }");
console.log( Array.prototype.pop.toString () === "function pop() { [native code] }");
// all true
BUY ΣJS JavaScript in Depth