BillyRayPreachersSon
Programmer
I'm trying to modify a piece of code that uses the instanceof operator so that it works on IE 5/Mac. With the instanceof operator in place, the code simply fails to do anything on the Mac. No errors are thrown, but the code simply fails to load (apparently, at least... an alert statement right at the top of the file isn't called, even though these lines are right near the bottom):
The replacement code I've come up with does at least run:
But I'm wondering if it will do the same job.
Does anyone know if the two pieces of code are technically the same? Would there be any situations where one works but the other does not?
Thanks!
Dan
[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
Code:
if (obj instanceof Date) {
// do something with obj here
} else if (obj instanceof Array) {
// do something with obj here
}
The replacement code I've come up with does at least run:
Code:
if (obj.constuctor == new Date().constructor) {
// do something with obj here
} else if (obj.constuctor == new Array().constructor) {
// do something with obj here
}
But I'm wondering if it will do the same job.
Does anyone know if the two pieces of code are technically the same? Would there be any situations where one works but the other does not?
Thanks!
Dan
[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]