When testing with alert-boxes I got tired of writing the same name twice
like this:
alert ('variablename =' + variablename);
and wrote a helper function :
var alertt = function (a) {
var result = 'Variable name and value\n';
for (var i = 0; i < arguments.length;i += 1) {
result += arguments[i] + ' = ' + eval(arguments[i]) + '\n';
}
alert(result);
return result;
}
// testing the above function ------------------------
var ss = 'something';
var number = 3;
var b = true;
var scope = this;
alertt('ss','number','document.lastModified','Math .random()','b','scope');
// the above code creates an alert box like this (tested in ie6.0, ff3.01,
opera9.02 only)
Variable name and value
ss = something
number = 3
document.lastModified = 09/01/2008 21:24:00
Math.random() = 0.39872433505681937
b = true
scope = [object Window]
--------------------------
Do you find even easier way, where one could omit quotes?
Also other improvements are welcome.