JavaScript: Same code take different time to execute
First i run this (in chrome):

    var start;
    var end;
    
    start = (new Date()).getTime();
    
    for(var i=0;i<10e5;i++);
    
    end = (new Date()).getTime();
    
    console.log('delay:' + (end-start));

Output: **`delay:2028`**  
Then I run this:

    function foo() {
        var start;
        var end;
        
        start = (new Date()).getTime();
        
        for(var i=0;i<10e5;i++);
        
        end = (new Date()).getTime();
        
        console.log('delay:' + (end-start));
    }
    
    foo();
Output: **`delay:8`**

Why took the same code shorter time when wrappered in a function?

_In node it took the same time (6 and 6), but node uses the V8 engine by the chrome isn't it?_
JavaScript: Same code take different time to execute
===

First i run this (in chrome):

    var start;
    var end;
    
    start = (new Date()).getTime();
    
    for(var i=0;i<10e5;i++);
    
    end = (new Date()).getTime();
    
    console.log('delay:' + (end-start));

Output: **`delay:2028`**  
Then I run this:

    function foo() {
        var start;
        var end;
        
        start = (new Date()).getTime();
        
        for(var i=0;i<10e5;i++);
        
        end = (new Date()).getTime();
        
        console.log('delay:' + (end-start));
    }
    
    foo();
Output: **`delay:8`**

Why took the same code shorter time when wrappered in a function?

_In node it took the same time (6 and 6), but node uses the V8 engine by the chrome isn't it?_