Link to home
Start Free TrialLog in
Avatar of chima
chima

asked on

ExpressionNoIn in Javascript and other languages

Hello,
What does the "NoIn" as in ExpressionNoIn mean.  I found it here;
http://tomcopeland.blogs.com/EcmaScript.html

Used in the Javascript For loop, opt is a subscript, which does not show it here;
for ( ExpressionNoIn opt ; Expression opt ; Expression opt )

As shown here; http://es5.github.io/  and in the ECMAScript 5.1

I know how the for loop work, no need to explain that   :)
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I know how the for loop work
But do you also know this variant:
var a = ['a', 'b', 'c']; 
for (var i in a)
{
    alert(i + ': ' + a[i]);
}

Open in new window

On the link Dave posted, it is explained in 12.6.4 and ExpressionNoIn is defined at the very bottom of A.3

So I would say it is used to define that you cannot use the 'in' variant of an expression combined with the 'normal' variant of the for statement (using semicolons). Something quite logical probably but which they had to define in the language with a very elaborate rewrite doubling up a lot of the existing definitions...
I had never seen that before.  Tried it, it worked.
Avatar of chima
chima

ASKER

robert_schutt, I understand the code sample you posted, but I can't understand the
http://www.ecma-international.org/ecma-262/5.1/

And about section A.3 - Annex A (informative) Grammar Summary it is just more of the same :)

May I ask you a question about this section?
See >>> below, more than one.
12.6.4 The for-in Statement

The production IterationStatement : for ( LeftHandSideExpression in Expression ) Statement is evaluated as follows:

Let exprRef be the result of evaluating the Expression.
>>> The expession mentioned here is the "far right Expression" in the code/statement...right?

Let experValue be GetValue(exprRef).

If experValue is null or undefined, return (normal, empty, empty).
>>> Why are there three; "normal, empty, empt"  Isn't there only "null and undefined"?

Let obj be ToObject(experValue).

Let V = empty.
>>> What is "V" here? (this is the most important question).

Thank you, your code sample help;
My understanding is that you could not do this;
var a = ['a', 'b', 'c'];
for ( (var in a) ; Expression opt ; Expression opt )

Which does not make sense relative to the other expressions in the For loop.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One variant can use the "in" operator, and another variant must have no "in" operator. The first is expressed as simply {Expression}. The second is {ExpressionNoIn}. (I.e., {an Expression with no "in"}.)

That's really all it's trying to say.

Tom
Avatar of chima

ASKER

robert_schutt I greatly appreciate your comments and I do get your point.
Allow me to ask tliotta for one code example, if he wishes.

tliotta I think I know what you are saying, would think that the initial statement of;
for ( ExpressionNoIn opt ; Expression opt ; Expression opt )

would be (based on your comment; "The second is {ExpressionNoIn}. (I.e., {an Expression with no "in"}", would be shown as follows:
for ( ExpressionNoIn opt ; ExpressionNoIn opt ; ExpressionNoIn opt )

So, one code example would be greatly appreciated.
Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have to add a disclaimer that my comments are not "authoritative". They're purely from general experience and personal interpretation in case it helps spark useful insights. If I make sense and it helps, it might be coincidence.

Tom
Avatar of chima

ASKER

I apologize for the delay on issuing the points.  Thank you all.