jQuery Object Keys


/ Published in: jQuery
Save to your folder(s)

Simple snippet to return the keys of an object.


Copy this code and paste it in your HTML
  1. $.extend({
  2. keys: function(obj){
  3. var a = [];
  4. $.each(obj, function(k){ a.push(k) });
  5. return a;
  6. }
  7. })
  8.  
  9. // Useage:
  10. var obj = {a: 1, b: 2, c: 3, d: 4, kitty: 'cat'}
  11. alert($.keys(obj)); // a,b,c,d,kitty

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.