>> Another way of writing it is:
var elements = {'html':true}
var myElement = "html";
if( elements[myElement] ) {
alert("True");
}
That is _not_ equivalent to the `in' operation.
No luck there then, Rob. ;-) Imagine getting this guy a christmas gift.
I explained the operator _and_ referred the OP to the reference materials
that he obviously had never considered to read before posting.
I did make an effort to look for a defination of the in keyword,
however I couldn't find topics on it in the groups history or on google
search, lots of web pages appear to match the word "in". Also your faq
is does not have a list of keyword definations, considering the amount
of quizzes about the "this" keyword generally, this might be a good
idea. Whats more I do have an ECMAScript spec on my desktop, and this
is what I found under in operator:
11.8.7 The in operator
The production RelationalExpression : RelationalExpression in
ShiftExpression is evaluated as follows:
1. Evaluate RelationalExpression.
2. Call GetValue(Result(1)).
3. Evaluate ShiftExpression.
4. Call GetValue(Result(3)).
5. If Result(4) is not an object, throw a TypeError exception.
6. Call ToString(Result(2)).
7. Call the [[HasProperty]] method of Result(4) with parameter
Result(6).
8. Return Result(7).
return WTF???;
Forgive me, if I didn't have a burning fascination to find to crawl
through 188 pages worth at the time. Frankly it was just something that
I was mildly interested in. I really didn't think it would be such a
big deal for you.
Here is a new keyword for you: pedantic