Looping through arrays

- [Instructor] Loops are often used…to traverse arrays and perform actions…on one of, some of, or all of the items within them.…When we use a method like query selector all,…there's a good chance we get an array of results,…and we if we want to do something…like run a function on an item within that array,…a loop will help us go through them one at a time.…In the exercise files for this movie 09 02,…you'll find our trusty old Moonwalk Manor example.…Let's say we want to make sure…all external links in this document…have their target attributes set to _blank.…

For the purposes of this example,…we stipulate that all internal links are relative,…and external links have absolute URL's.…First, we create an array…inside the new variable extLinks.…And here I'm looking for only links…that start with http something.…So I can use document.querySelectorAll.…Here I'm going to use single quotes…and say a, square bracket href, and then a caret.…This means any link…that has the href attribute starting with…whatever I define,…and here I have double quotes inside, http.…

Resume Transcript Auto-Scroll

Author

Released

5/15/2017

JavaScript is a scripting language of the web. As the web evolves from a static to a dynamic environment, technology focus is shifting from static markup and styling—frequently handled by content management systems or automated scripts—to dynamic interfaces and advanced interaction. Once seen as optional, JavaScript is now becoming an integral part of the web, infusing every layer with its script.

Through practical examples and mini-projects, this course helps you build your understanding of JavaScript piece by piece, from core principles like variables, data types, conditionals, and functions through advanced topics including loops, closures, and DOM scripting. Along the way, you will also be introduced to some ES6 and the basics of JavaScript libraries.