TypeScript docs say nothing about loop like for
or for-in
. From playing with the language it seems that only any
or string
edit 2018: This is outdated, js and typescript now have for..of loops.
http://www.typescriptlang.org/docs/handbook/iterators-and-generators.html
The book "TypeScript Revealed" says
"You can iterate through the items in an array by using either for or for..in loops as demonstrated here:
// standard for loop
for (var i = 0; i < actors.length; i++)
{
console.log(actors[i]);
}
// for..in loop
for (var actor in actors)
{
console.log(actor);
}
"
Turns out, the second loop does not pass the actors in the loop. So would say this is plain wrong. Sadly it is as above, loops are untouched by typescript.
map and forEach often help me and are due to typescripts enhancements on function definitions more approachable, lke at the very moment:
this.notes = arr.map(state => new Note(state));
My wish list to TypeScript;