This link shows you that jQuery uses (new Function(\"return \" + data))();
for older browsers, to parse a JSON string instead of eval()
.
Wh
As to why jQuery specifically uses new Function()
, John Resig answered this on the jQuery forums
Using eval causes all sorts of problems for code minifiers since it's not clear what could be executing in the eval. Looking at the last results from that run it looks like new Function is fairly equivalent to eval and even slightly faster sometimes. The one exception was Safari 4 - but those results are dated, Safari 4 shipped with a native JSON.parse implementation, which we use.