jobo: jslint und Crockfords memoizer-Funktion

Beitrag lesen

Hallo,

Der letzte Satz erklärt wohl alles.

Erklärt aber nicht, warum das inkonistent ist, oder?

[script lang=javascript]
var testFn = function () {
    var dom = (function () {
        var ready = function (e) {
            //do something
        };
        return {
            contentLoaded: function (e) {
                if (dom.isReady) {
                    return;
                }
                dom.isReady = true;
                ready(e);
            },
            isReady: false
        };
    }());
};
// 2 Fehler
var dom = (function () {
    var ready = function (e) {
        //do something
    };
    return {
        contentLoaded: function (e) {
            if (dom.isReady) {
                return;
            }
            dom.isReady = true;
            ready(e);
        },
        isReady: false
    };
}());
// Fehlerfrei
[/code]

aus http://tech.groups.yahoo.com/group/jslint_com/message/2021

Gruß

jobo