Variable declaration outside or inside when using on of the methods of Array.prototype
Concerning your variable scope, I think it is safer to define it inside the function as it will assure you get the value inside it. That way you won't be able to access a filled in parts variable after your function - in this case it makes no difference, but once you have a couple more things going on it is best to declare your variables with as little scope as possible. This is because you variables will be cleaned up automatically after your function has ended (and garbage collection has come by), which means you are freeing up memory and not filling it with data you won't use anymore.

I have been able to eliminate almost all your variables because of returns. Instead of storing something when you just need to use it to return, just return it directly. It cuts down on a lot of variables, and a lot of code. 

The point is that you don't need to use variables unless you need to use them later. After deciding what variables to use, you have to decide what scope you need. Keep the scope as small as possible, so it's as predictable as possible to see what variable is available where and reduce memory consumption.



window.app = {
    combos: {
        a: 'A-A-B-C-C',
        b: 'A-B-C',
        c: 'A-B-C-C-D'
    },
    check: function () {
        // If like declaring variables at the top, it keeps the rest consistent
        return Object.keys(this.combos).forEach(function(combo){
            // `combo` is already defined, and since you don't use
            // this.combos anymore after this, dont store it in a var
            var parts = this.combos[combo].split('-').sort();
            // Also, I also recently came across this 
            // clever piece on Code Review:
            return parts.forEach(function(part, index){
                // To check duplicates, just check
                // if first index != last index
                if(index != parts.lastIndexOf(part)){
                    document.write('DUPLICATED PART IN: ' + combo + ' : ' + part + '&lt;br /&gt;');
                    // You can just return here.
                    // Breaks the loop and returns!
                    return false;
                }
                return true;
            });
        }, this);
        return result;
    }
}
    
document.write('&gt;&gt;&gt;' + (window.app.check() ? 'Completed without duplicates' : 'Duplicates found.'));




I also replaced your alert with document.writes as alerts are just... annoying in my opinion. Check the snippet above to see a nice result.

One more thing: if you do want to bind a this arguments to forEach, it already provides a quick way to do that: the second argument of the forEach function is actually defined as thisArg:

arr.forEach(callback[, thisArg])


Your assumption is correct: variables declared within blocks are scoped only to that block. If, however, you omit the keyword var, they will be avail;able outside your block as they are usually appended to the top-level object in the chain, usually the window.



document.write('Executing a function that uses &lt;code&gt;var&lt;/code&gt; to declare local scope.&lt;br /&gt;');

+function(){
    var foobar = 'Foo Bar';
}();

document.write(typeof foobar !== 'undefined' ? '&gt;&gt;Foobar is ' + foobar : '&gt;&gt; Foobar is undefined. &lt;br /&gt;');

/*-------------------------------*/

document.write('Executing a function that does not use &lt;code&gt;var&lt;/code&gt; to declare local scope.&lt;br /&gt;');

+function(){
    foobar = 'Foo Bar';
}();

document.write(typeof foobar !== 'undefined' ? '&gt;&gt; Foobar is: ' + foobar : '&gt;&gt; Foobar does not exist &lt;br /&gt;');

/* Note: using the + sign is equal to wrapping the function in brackets etc... Its create a temporary scope an executes in it. */