Miscellaneous Differences
Other differences between Navigator and Internet Explorer 3.0 are small details about the way values are computed and printed:
- The
for/instatement in IE 3.0 does not always enumerate the same object properties that Navigator does. It does enumerate all user-defined properties, which is its primary function. But predefined properties of built-in objects are not always listed. - The && and || operators behave somewhat differently in Navigator and Internet Explorer, although, since JavaScript is an untyped langauge, the difference is usually irrelevant. When the first operand of the
&&operator evaluates totrue, then the operator returns the value of the second operand in Navigator. In Internet Explorer, this second operand is first converted to a Boolean value, and that value is returned. Thus the expressiontrue && 10
evaluates to10in Navigator but totruein Internet Explorer. This may seem like a major difference, but because JavaScript is an untyped langauge, it rarely matters. The&&operator is almost always used in a Boolean context, such as the expression of anifstatement, so even when Navigator returns a value like10, that value will be immediately converted to the Boolean valuetruewithin that context. The same evaluation difference occurs when the first operand of the||operator evaluates tofalse. - In Internet Explorer 3.0, Boolean values implicitly are converted to strings differently than they are in Navigator. The value
trueis converted to the string-1, and the valuefalseis converted to the string0. If you actually want them to be converted to the strings "true" and "false", you must convert them explicitly by adding them to the empty string. - User-defined function values are also converted to strings differently in IE 3.0. In Navigator, functions are converted to a string that includes the complete body of the function. In fact, you can even use
eval()function to define the function in some other window. This does not work in Internet Explorer, which omits the function body from its string representation of functions.