how to see all object attributes?
|
| View previous topic :: View next topic |
| Author |
Message |
AmeliaR Enthusiastic Coder
Joined: 31 May 2006 Posts: 142
|
How do I see all object attributes/properties ?
I try for (x in arr){ alert(arr[x]);}
But it shows only value
Reply with quote
|
| |
|
|
Kopilman Enthusiastic Coder
Joined: 25 May 2006 Posts: 162
| |
AmeliaR Enthusiastic Coder
Joined: 31 May 2006 Posts: 142
| |
Kopilman Enthusiastic Coder
Joined: 25 May 2006 Posts: 162
|
But I don't have a nicer solution that doesn't involve tons of alerts.
Reply with quote
|
| |
|
|
AmeliaR Enthusiastic Coder
Joined: 31 May 2006 Posts: 142
|
Can I concatenate all pairs in a string ?
Like alert (concat(o)) ?
So it shows k=>v pairs
Reply with quote
|
| |
|
|
Kopilman Enthusiastic Coder
Joined: 25 May 2006 Posts: 162
| |
AmeliaR Enthusiastic Coder
Joined: 31 May 2006 Posts: 142
| |
Lusis Backwood JR Enthusiastic Coder
Joined: 26 May 2006 Posts: 87 Location: United States
|
Function foo(o) { var a = []; for(var p in o) a.push(p); a.sort(); for(var i = 0; i < a.length; i++) a[i] = a[i]+'='+o[a[i]]; alert(a.join('\n')); }
Foo(someobject);
Reply with quote
|
| |
|
|
AmeliaR Enthusiastic Coder
Joined: 31 May 2006 Posts: 142
| |
|