View Full Version : A tiny Javascript help
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.
Code Monkey
08-07-2006, 01:28 AM
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;
}
}
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;
}
}
Thanks.
I get "Type: object Value: [object] ".
Code Monkey
08-07-2006, 02:45 AM
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.
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.
Is there a way to get it to show objects?
Code Monkey
08-07-2006, 03:18 AM
Are you trying to find all objects are see if a particular object is defined?
Trying to see all objects to a varible.
Code Monkey
08-07-2006, 03:25 AM
I'm not sure I understand what it is you want to do.
I have 'this.****' I want to find out what everything that is in it and named.
Code Monkey
08-07-2006, 03:38 AM
Then just use the code above.
var_dump(this.varname);
Then just use the code above.
var_dump(this.varname);
But I dont know the varname. I want to see all of them.
Code Monkey
08-07-2006, 04:04 AM
Oh, I'm not sure that can be done.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.