15
rated 0 times
[
22]
[
7]
/ answers: 1 / hits: 62996
/ 14 Years ago, wed, january 5, 2011, 12:00:00
Are these two functions doing the same thing behind the scenes? (in single statement functions)
var evaluate = function(string) {
return eval('(' + string + ')');
}
var func = function(string) {
return (new Function( 'return (' + string + ')' )());
}
console.log(evaluate('2 + 1'));
console.log(func('2 + 1'));
More From » function