JSON Performance comparison of eval and new Function

JSON Performance comparison of eval and new Function

Hello,

Why new Function is used in the code below instead of eval?

According to this blog post eval is generally faster.


  1. // Try to use the native JSON parser first
  2. return window.JSON && window.JSON.parse ?
  3. window.JSON.parse( data ) :
  4. (new Function("return " + data))()