T
Thomas 'PointedEars' Lahn
VK said:By "not far enough" you mean NN 2.x - NN 4.x ?
Not only, but they are included. At least NN 4.x definitely is.
IE supports it since 3.02
So? IE is probably the widest distributed, but not the only user agent
around. And the `in' operator has AFAIS not been specified in ECMAScript
before Edition 3.
If some other browser still doesn't have it implemented properly, the
primary task would be to see such browser disappeared from the human
memory as quick as possible, rather than support it an any way.
Let's just say your perception of reality appears to me to be somewhat
strange.
The most important is that if (someObject) method fails easily in too
many curcumstances appeared after prototypes and constructors
introduction.
Nobody unconditionally recommended `if (someObject)', instead you
used it as vessel for your "argumentation". You are confused, yes?
Check this
(... not Valid ...)
sample:
<html>
<head>
<title>Testcase</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function test() {
self.abort = undefined;
So you had to construct a less-than-probable case to prove
your otherwise unfounded assumption. You made my day.
// Good practice:
No, it is not. The "in" operator is certainly a viable approach, but since
it lacks wide support, it cannot be considered best practice or even good
practice. But then you have seldom, if ever, bothered with such details.
Your experience in JS programming is still (despite several attempts of
explanation by experts to you) questionable at best. Since this is not
the first time, I strongly advise you read more before you post further
such bold statements here.
alert(self.hasProperty)
Your point being?
Where did you get method? You mean HasProperty moniker from .Net
framework? It has no relation with the discussion.
No, I mean(t) Object.prototype.hasOwnProperty() as specified in
ECMAScript 3 and implemented in JavaScript 1.5+, JScript 5.6+.
Since I seldom have to use it, I remembered the identifier wrong.
Why in the name you need to check the type of property in question?
Because that is the most viable approach to check it exists in the
sense that it refers to useful value.
What can it prove?
It can prove that it is not undefined, i.e. that it was not defined or
assigned undefined. It also can prove that the call operator may be
applied to it (see below).
Even if it's indeed a method (so it's typeof "function"),
.... or typeof ... == "object", for IE's DOM objects
what proof do you have that this is *that* method and not
some bogus?
I don't have. However, it has proven to be a viable approach to expect
methods that are named as documented to do what is documented, with only
a few exceptions in the implementation of the W3C DOM in IE.
I know when I mess with those methods in my included scripts and I know
who to blame then if it does not work. And since JS's object model is
dynamic, if either the UA's vendor or the user decide to cripple its
client-side script support or DOM, there is nothing a JS developer can
do about it. As JS/ECMAScript developer you always have to cope with the
host environment it runs in. So I simply don't need to bother with it.
For example if a property called `document.getElementsByTagName' exists
and it is a method, I have to assume that it can be called and returns
either `null', a HTMLCollection or not a HTMLCollection. Of course I
have to check its return value in some way before referring to it.
And even if it's indeed *that* method, what proof do you
have that it was implemented as documented? You can only protect
yourselve from initial "Object expected error" by doing
if ( (neededObject in self) && (neededStuff in neededObject) ) {...}
Rubbish. There cannot be such an error produced (and it can only in IE)
unless the call operator is applied to a non-undefined property or the
object model the host environment is completely broken. However, I
consider implementations that return something other than "function" or
"object" for a method to be badly broken, and so I do not support them.
The rest remains in the hands of the Lord and browser makers.
No, there are certain standards specified to adhere to, and UA vendors
state in the documentation what standards they support. Most of the time,
those statements have proven to be correct.
"self" has the only context to be.
You are talking nonsense. `self' has been and it is still a property of
Window objects, not by definition of the Global Object. Get yourself
informed, please.
Unless you've created a "self" variable and did your whole script dizzy:
self = something;
// var self = something ?
// window.self = something ?
...
That proves or disproves which one of my arguments? Again you are virtually
*constructing* something to try and fail to prove one of your arguments.
As "self" is one of so-called "tasty words" for identifiers, I see this
happens here and there and should be each time pointed.
Pardon? You are the one who suggested using `self' in the first place.
Unfortunately, I more and more get the impression that you do not really
know what you are talking about nor, more important, do you have any idea
what you are argueing against/for. Maybe a pillowful of decent sleep will
help you. Goodnight.
PointedEars