Home > Articles > Open Source > Ajax & JavaScript

  • Print
  • + Share This
This chapter is from the book

Summary

In this chapter, we started off by diving a little deeper into variables. You learned the different grouping options when declaring variables, along with some best practice considerations like why you should declare variables at the top of your JavaScript document. We also went over the list of reserved terms you should consider when naming functions and variables to help prevent collisions in your scripting file.

After that, we elaborated on the different types of functions, how they differ from each other, and discussed different case scenarios for when you might want to use each type of function. We talked about basic functions, anonymous functions, callback functions, and functions in objects, along with how to get your functions working together by returning and passing data to one another, returning both single and multiple values.

Before this chapter, we were accessing items directly when working with data. This chapter showed how to execute the same code over and over for each data item in the form of a loop. We learned about the for loop specifically and talked about performance considerations and why the loop is assembled in the way it is.

After loops, we got into conditionals in the form of if/else and switch statements. They appear similar on the surface, but we also talked about why they’re different and the scenarios where you may want to use one style over the other.

This chapter was the first step in building a real JavaScript application (an address book). In the next chapter, we start to bring users into the mix when we talk about events, how we might apply user interactions to this application, and learn some general information about events in JavaScript.

  • + Share This
  • 🔖 Save To Your Account