Typescript Iterations – Brief and simple explanation

Kategorien for loops, Start Coding, Typescript
typescript-forloops

You may ask yourself what is better and much smother with typescript then javascript?
Just look at the new typescript iterations, they are so easy to read and to programm.

There are two types of for iteration in typescript

  • for … in
  • for … of

To learn what the difference between these loops are I got an crib for you so you can remember that better.

for … IN loops throw the INdex of the array
for … OF loops throw the values of the array

Here is an brief example:

Keep in mind that using an for … OF loop on non-Array values, will get you an error.

Hope you enjoyed this little tutorial about for loops in typescript, hopefully see you soon.
Make sure to comment this post if something is unclear also let me know if you want more of this little Tutorials. Also check out my Post about Software Development https://modev.net/software-development-overview/

 

Soruce: https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html

1 Gedanke zu „Typescript Iterations – Brief and simple explanation

  1. Please let me know if you’re looking for a writer for your weblog. You have some really good posts and I believe I would be a good asset. If you ever want to take some of the load off, I’d really like to write some content for your blog in exchange for a link back to mine. Please shoot me an email if interested. Cheers!|

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.