Randy Webb wrote:
What are the advantages/disadvantages of using function (evt) over using
a new Function construct?
A function expression
= function (arg) { function body }
is (in my view) the simpler and more natural way to write an expression
that evaluates to a function.
Constructing a function with the Function constructor
= new Function("arg", "string with function body code")
is only needed if you need to construct the parameter name and/or
function body code at runtime from a string. It is much like eval in
that at run time string with source code needs to be evaluated. If you
only use eval if really needed (e.g. you need to construct code at
runtime depending on user input) then you should only use new
Function("code") the same way.
--
Martin Honnen
http://JavaScript.FAQTs.com/