Welcome to MSDN Blogs Sign in | Join | Help
For-in in JScript

For-in the JScript is unique to other languages, in a way that it iterates over the keys, where as in most other languages ( C#, Python.. ), it iterates over the values.

 
var location = { x : 100, y : 200 }
for (var i in location) { print(i); }

would give the following output
x

y


Now, suppose the location was not a Jscript object, but a .NET object. ( from C#). This gives a interesting issue. What should be printed in the above case?
Should it be 100, 200 or x, y ?
In the Managed Jscript, it iterates ove
r the keys, because thats what a Jscript programmer would expect, irrespective of, from where the object came from.

Posted: Monday, May 07, 2007 9:54 AM by jitu
Filed under: ,

Comments

No Comments

Anonymous comments are disabled
Page view tracker