In this lesson we're going to look at another type of for loop, the …enumerative for loop. This is one that you can use on arrays or objects. …And it's very useful, but you need to be a little careful with it. …So here I have a couple of code samples. First we'll look at iterating over an …array with this thing. I have this variable called page names, …it's an array, it's six items. Now to iterate over this using techniques …we know, I would use a for loop where I'm setting I to zero, going up to the …length of the page name's array, and incrementing I every time. …There's another way to do this using for n, the enumerative for loop.…
This is what it looks like. I have for, followed by parentheses. …And then the expression inside is var, and then I can choose whatever variable …name I want. I'm using p in this case. …In, then the name of the object, or in this case, array over which I'm going to iterate. …So, what happens is this loop will execute as many times as there are …enumerable objects in the array. Generally speaking, that's going to be …
- Enabling Firebug and web inspectors
- Using a text editor
- Declaring and assigning a variable
- Booleans and the quest for truth
- Working with objects and arrays
- Using operators and control structures
- Iterating with loops
- Objects, references, and functions
- Understanding variable scope
Skill Level Beginner
Q: In "How to enable Firebug and web inspectors," at the Chrome Canary part, the author mentions going to the View menu, and then Developer. My Canary has no menu bar. The author uses a Mac, whereas I have Windows. How do I get to the same place?
A: Click the menu button at the top right of Chrome, select More Tools, and then choose Developer Tools.
1. Getting Started
Our friend, the text editor3m 35s
2. Variables and Types
3. Objects, Arrays, and More
4. Operators and Control Structures
5. Iterating with Loops
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.