Return to Snippet

Revision: 10203
at December 12, 2008 09:43 by garside


Initial Code
$.extend({
    keys:    function(obj){
        var a = [];
        $.each(obj, function(k){ a.push(k) });
        return a;
    }
})

// Useage:
var obj = {a: 1, b: 2, c: 3, d: 4, kitty: 'cat'}
alert($.keys(obj));    // a,b,c,d,kitty

Initial URL
http://groups.google.com/group/jquery-en/browse_thread/thread/3d35ff16671f87a2\

Initial Description
Simple snippet to return the keys of an object.

Initial Title
jQuery Object Keys

Initial Tags
object, jquery

Initial Language
jQuery