Here are a few functions that you might find helpful when working with JavaScript. These assume operation in a Browser (which makes a good experimental platform). In particular, the first function below sends output to a Browser window. If you were writing a Seibel Business Service, you might write to a Trace Log.
function Print ()
{
// Use the DIV element to style the output!...
document.writeln('<div class="JSOut">');
for (var
ix=0; ix < arguments.length; ix++)
{
document.write (arguments[ix]);
}
document.writeln('');
document.writeln('</div>');
}
This function iterates over the Properties of any Object.
function Print_Object (obj)
{
Print ("OBJECT:");
for (var
px in obj)
{
Print (px, '=', obj[px]);
}
}
Just a handy Array Printer.
function Print_Array (arr)
{
Print ("ARRAY:");
Print ("Len=", arr.length);
for (var
ix=0; ix < arr.length; ix++)
{
Print (ix, ': ', arr[ix]);
}
}
(back) | § | Top | Web | JavaScript | Tutorial |
---|