Click to See Complete Forum and Search --> : The question mark???
SugarGirl
03-25-2003, 10:05 AM
What does the ? and the : mean in javascript???
Example:
this.scrollbarBot.style.top = (MenuHeight - (HM_IE ? (HM_BorderWidth * 2) : 0) - HM_ScrollBarHeight) + "px";
khalidali63
03-25-2003, 10:21 AM
var isOK = (n==1)?true:false;
the above is equivalent of
if(n==1){//?
isOK = true;
}else{//:
osOK = false;
}
Hope this helps
Cheers
Khalid
pdgguy
03-25-2003, 10:22 AM
In basic terms:
a ? x : y
If a is true, compute and return the value of x; if a is false, compute and return the value of y
Sean
havik
03-25-2003, 10:24 AM
The best way I can describe it is to look at the following statement:
var temp = (document.all ? true : false);
the variable temp gets the value true if the argument document.all happens to be true and false for false.
In your example, HM_IE is the argument and if it is true, then MenuHeight is subtracted by HM_BorderWidth. If false, then MenuHeight is subtracted by 0 (essentially it is not subtracted).