METHOD:
Function::toSource
Function.toSource
()
The toSource method creates a string representing
the source code of the function. This over-rides the Object.toSource
method. Although the toSource method is usually called
by JavaScript behind the scenes, you can call it yourself. This can
be particularly useful when debugging. In the case of the built-in Function
object, it returns a string indicating that the source code is not available,
while, for a user-defined function, toSource will return
the JavaScript source that defines it as a string. The following examples
illustrate these uses:
Function.toSource() returns:
function Function() { [native code] }
function Cat(breed, name, age)
{
this.breed = breed
this.name = name
this.age = age
}
Cat.toSource() returns:
function Cat(breed, name, age) { this.breed = breed;
this.name = name; this.age = age; }
Sheeba = new Cat("Manx", "Felix",
7)
Sheeba.toSource() returns:
{breed:"Manx", name:"Felix",
age:7}
|