Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>with the <code>new Function</code>-syntax, for every function the JS-compiler has to be started to "eval" the function body string - this is slow and should be avoided when possible:</p> <blockquote> <p>Each time […] the Function constructor is called on a string representing source code, the script engine must start the machinery that converts the source code to executable code. This is usually expensive for performance – easily a hundred times more expensive than a simple function call, for example. (Mark ‘Tarquin’ Wilton-Jones)</p> </blockquote> <p>if you had used the search on StackOverflow, you would have found <a href="https://stackoverflow.com/q/3026089/288773">this question</a> wich give very good and detailed information about that.</p> <p><strong>EDIT:</strong> like Martin said in one of the comments below, <em>sometimes</em> the <code>new Function</code>-constructor is a great thing. to list some examples:</p> <ul> <li><a href="http://ejohn.org/blog/javascript-micro-templating/" rel="nofollow noreferrer">John Resigs Micro-Templating Engine</a></li> <li><a href="https://stackoverflow.com/questions/3026089/legitimate-uses-of-the-function-constructor/3026622#3026622">This piece of code from another Question an SO</a></li> <li>to be continued...</li> </ul> <p>but: in 99% of the cases where you <em>could</em> use <code>new Function</code>, it's a bad idea - wich means: to simply define any function that has to be like it is and doesn't have some kind of "dynamic bahavior", you should always use the "normal" function-syntax to speed up your code and avoid the <code>eval</code>-like functionality of <code>new Function</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload