In order to reduce interferences between several scripts, I know it's highly recommended to encapsulate the Javascript code. But how would you do it? Which would you consider a better script between the following?:

Function 1:

PHP Code:
euler2 = {
    
getSumEven: function(limit) {
        
this.total 0
        
this.0
        
this.1
        
this.abSum 1;
        do {
            
this.this.b;
            
this.this.abSum;
            
this.abSum this.this.b;
            if (
this.abSum == 0this.total += this.abSum;
        } while (
this.abSum <= limit)
        
console.log('euler2. Total: ' this.total);
    }
};

euler2.getSumEven(4000000); 
Function 2:

PHP Code:
(function(limit) {
        var 
total 0
        
0
        
1
        
abSum 1;
        do {
            
b;
            
abSum;
            
abSum b;
            if (
abSum == 0total += abSum;
        } while (
abSum <= limit)
        
console.log('euler2. Total: ' total);
})(
4000000); 

I could even exchange the way I use variables so that Function 1 could use local variables as such, and Function 2 would use function properties, and it would also work.

Which way to use better? Which way to use variables?