function returner() { return 100; } function profiler(aFunction) { var begin = new Date(); for (var i = 0; i < 500000; ++i) { aFunction(); } var end = new Date(); return end - begin; } function profileLambdaExpression() { // lamda expression print("lamda expression : " + profiler(function () returner()) ); // equal to above expression print("normal form : " + profiler(function () { return returner(); }) ); // not return the value print("return no value : " + profiler(function () { returner(); }) ); } profileLambdaExpression();
>> lamda expression : 1521
>> return no value : 1431
SpiderMonkey 1.8.0 pre