Iterating a JavaScript object's properties using jQuery

tags2k picture tags2k · Jul 8, 2009 · Viewed 104.1k times · Source

Is there a jQuery way to perform iteration over an object's members, such as in:

    for (var member in obj) {
        ...
    }

I just don't like this for sticking out from amongst my lovely jQuery notation!

Answer

Tim Büthe picture Tim Büthe · Jul 8, 2009
$.each( { name: "John", lang: "JS" }, function(i, n){
    alert( "Name: " + i + ", Value: " + n );
});

each