JS: 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; }" );
const ff = (x => 3);
console.log( ff.toString () === "x => 3" );
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] }");