ym*@kicon.com (chirs) writes:
These 2 lines caused an error in IE5. The error is "Function
expected". Why?
var d=new Date();
document.write(d instanceof Object + "<br>");
It gives an error in Opera 7 too. Since Opera isn't IE, you can
actually use the error message:
Statement on line 2: Second argument to 'instanceof' is not an
Object: Object + "<br>"
So, the problem is the association. It first adds Object and "<br>",
giving a string, and then tries to see whether d is an instance of
that string. And you can't be an instance of a string, only of a
function, which is why IE expected a function..
Add brackets:
document.write((d instanceof Object) + "<br>");
Then it works in Opera 7, and it writes "true<br>" to the document.
(and "instanceof" has been in JScript since version 5 and Javascript
since ersion 1.4, and is a part of ECMAScript, and Object is a function
in Javascript since version 1.0).
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'