Are these two functions doing the same thing behind the scenes? (in single statement functions)
var evaluate = function(string) {
return eval(\'(\' + str
No.
In your update, the calls to evaluate and func produce the same result. But, they are most definitely not "doing the same thing behind the scenes". The func function creates a new function, but then immediately executes it, whereas the evaluate function simply executes the code on the spot.
From the original question:
var evaluate = function(string) {
return eval(string);
}
var func = function(string) {
return (new Function( 'return (' + string + ')' )());
}
These will give you very different results:
evaluate('0) + (4');
func('0) + (4');