For the built-in Function object, toSource() returns the following string indicating that the source code is not available:
function Function() {
[native code]
}
For custom functions, toSource() returns the JavaScript source that defines the object as a string.
@reference_1_mozilla
eval
as a string defining function requires "(" and ")" as prefix and suffix
var fctStr1 = "function a() {}"
var fctStr2 = "(function a() {})"
var fct1 = eval(fctStr1) // return undefined
var fct2 = eval(fctStr2) // return a function
@reference_2_mozilla
No comments:
Post a Comment