How to use function toString methods in Javascript

Description

For functions, the methods toLocaleString() and toString() always return the function's code.

Example


var f = function sayColor(){ 
   console.log("asdf"); 
} 
console.log(f.toLocaleString());

The code above generates the following result.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions