JavaScript For In & For Of Loops #JavaScriptJanuary

Watch the entire #JavaScriptJanuary series from the beginning!
https://www.youtube.com/playlist?list=PLkwxH9e_vrALlH7D0XLDn2td-uoHqHFxq

“For In” and “For Of” are ways to loop through objects or arrays.

“For In” loops through property names of an object. Remember that objects are made up of property, or key, value pairs. In order to get the values we will need to reference the original object and use square brackets to define the property.

“For In” will work with an array. Instead of a named property it will use the index of each value. In order to get the values we would have to reference the original array and use square brackets to define the index of the value. A better solution would be to use “For Of”.

“For Of” loops iterate through items in a collection such as an array. It’s very similar to the “For In” except this time we are using the “of” keyword and passing it an iterable instead of an object.

So if we use a “For Of” loop with an array then we will not have to reference the original array using indices. It will just give us the values directly.

Note that “For Of” will not work with Objects because they are not iterable. And just remember that “For In” is for Objects and “For Of” is for Arrays.

I’ll be releasing a new video every day in January! Stay tuned..

————————————————————

📚 My Favorite Web Design Books 📚
Web Design with HTML, CSS, JavaScript and jQuery Set by Jon Duckett (paid link)
https://amzn.to/2JaiCL8

🚀🚨 Web Hosting Squared (Affiliate Link) 🚨🚀
https://www.webhostingsquared.com/aff.php?aff=3

🙏 Become a Patron: Show support! 🙏
https://www.patreon.com/codestackr

🌐 Website 🌐
http://www.codestackr.com

💖 SUBSCRIBE for more web development content 💖
https://www.youtube.com/codestackr/?sub_confirmation=1

🔗 Share this video with a friend 🔗
https://youtu.be/c5a4sNshBA4

📺 Watch next 📺
➞ Visual Studio Code Web Dev Setup in 6 Mintues: https://youtu.be/4NfFFsQC77M
➞ Learn Sass in 30 Minutes: https://youtu.be/BDOzg4lXcSg
➞ JavaScript Tutorial for Beginners: https://youtu.be/d5ob3WAGeZE

🎥🔥 Recommended Playlist 🔥🎥
https://www.youtube.com/playlist?list=PLkwxH9e_vrAJ0WbEsFA9W3I1W-g_BTsbt

——————————–
📢 Social Media 📢
——————————–
TWITTER (@codestackr) ➞ https://twitter.com/codestackr

INSTAGRAM (@codestackr) ➞ https://www.instagram.com/codestackr/

———————

** Affiliate Disclaimer: Some of the above links maybe affiliate links, which may generate me a sales commission. As an Amazon Associate I earn from qualifying purchases.

#JavaScriptJanuary #31Days31Videos #codeSTACKr

Post Author: hatefull