March 21, 2000 - Calls By Reference
March 21, 2000 Calls By Reference Tips: March 2000
Yehuda Shiran, Ph.D.
|
new
operator.
Let's take an example that shows the differences between call-by-reference and call-by-string. The function setVisibility()
sets the visibility of a passed-by-string element:
function docjslib_setVisibility(id, flag) {
if (NS4) {
var str = (flag) ? 'show' : 'hide';
eval("document." + id).visibility = str;
}
else {
var str = (flag) ? 'visible' : 'hidden';
eval("document.all." + id).style.visibility = str;
}
}
The following function sets the visibility of elements that are passed by reference (objects):
function docjslib_setElementVisibility(id, flag) {
if (NS4) {
var str = (flag) ? 'show' : 'hide';
eval(id).visibility = str;
}
else {
var str = (flag) ? 'visible' : 'hidden';
eval(id).style.visibility = str;
}
}
Learn more about DOCJSLIB 4.0 in Column 33, DOCJSLIB Version 4.0: Scrollers, Watermarks, and Games
.