The Arcive of vBulletin Modifications Site. |
|
|
#1
|
||||
|
||||
|
I need a way to view all varibles even if I dont know the name of each one in Javascript.
Something like var_dump in php. |
|
#2
|
||||
|
||||
|
Code:
function var_dump(obj) {
if(typeof obj == "object") {
return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
} else {
return "Type: "+typeof(obj)+"\nValue: "+obj;
}
}
|
|
#3
|
||||
|
||||
|
Quote:
I get "Type: object Value: [object] ". |
|
#4
|
||||
|
||||
|
That's a standard php var_dump simulator for javascript that can be found a million places on the net. It simulates var dump which does not give you all variable values. Only the one you use the function on.
|
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
||||
|
||||
|
Are you trying to find all objects are see if a particular object is defined?
|
|
#7
|
||||
|
||||
|
Trying to see all objects to a varible.
|
|
#8
|
||||
|
||||
|
I'm not sure I understand what it is you want to do.
|
|
#9
|
||||
|
||||
|
I have 'this.****' I want to find out what everything that is in it and named.
|
|
#10
|
||||
|
||||
|
Then just use the code above.
var_dump(this.varname); |
![]() |
|
|