00:25 All the major browsers support tools like these. Most have similar capabilities. The names, shortcut keys, and locations in the menus are going to be different but if you Google “debugger” and your browser name, you should be good. In Firefox, the developer tools open in a split pane with a whole bunch of tabs.
03:26 Try to format your code in a matter consistent with the codebase you’re working in and you’ll have more friends. Inside of the curly brackets is the code block with the print-like statement that is being looped over.
It uses the variable
i to indicate the index of the loop. Each time in the loop, you’ll get each item of the
fibonacci array printed out. The definition of the index variable
i happens in the declaration of the
The second area is the boundary check. Here, I’m checking to see if
i is still less than the length of the
fibonacci array. If so, the loop body will be executed. After the execution of the loop body, the third area gets run. In this case, I’m incrementing the variable
i, and everything starts over again.
04:45 It isn’t much fun to play in the browser without doing browser stuff, so I’m going to visit Real Python. Notice that the console has been cleared. The other tabs show you information about the page being displayed, such as the HTML, what files were downloaded from the network, how fast things were loaded, and more. Inside the console, you’re still in a REPL-like environment, but now there’s a whole bunch of context available.
07:55 This is the alert box. The look and feel of the alert box is browser-specific. This is why you don’t see it often anymore. Most web pages create their own modal dialog boxes to be consistent with the look and feel of the site.
These will be run as soon as the browser sees them. Or, and generally considered the best practice, you can keep your code in a separate file and use the
<script> tag to load it from the server.
08:41 Here’s a sample HTML file with all of these methods. The first tag loads from a fully qualified source, server.com/library.js. The second tag loads from a relative source—that means the same server that the HTML file came from.
09:09 They can appear in the header or body section. The browser doesn’t care where you declare it, but do note that things get run in order. If your code tries to manipulate part of the document before it has loaded, you will get errors.
Become a Member to join the conversation.