Chapter 2

JavaScript Primer

WHAT’S IN THIS CHAPTER?

  • Understanding JavaScript Primitives
  • Using Variables, Functions, and Objects
  • JavaScript Scope, Closures, and Execution Context

It’s easy to forget that jQuery is a JavaScript framework; after working with it for an appreciable amount of time, jQuery seems and feels almost like its own language. Inside the jQuery source, examples are abound of how to apply great JavaScript techniques. However, to truly master jQuery, you must master JavaScript. JavaScript is a very powerful and expressive language. All the major browsers support it, it’s the driving force in modern web applications utilizing Ajax, and now it’s made a major debut on the mobile web platform.

JavaScript inherits some names and naming conventions from the Java language, but that’s about it. In contrast to Java, JavaScript is a dynamically typed, object-oriented scripting language that runs in a host environment, usually a web browser. It contains no classes, and uses prototypes for inheritance. It also has functional programming features; closures, functions as first-class objects, anonymous functions, and higher order functions. In reality, JavaScript is closer to a language like Lisp than it is to Java.

This chapter revisits a subset of JavaScript syntax necessary for understanding how jQuery works, its core, and how to better apply it to your projects. It begins with a brief review of data types and object-oriented programming, and then delves into functional ...

Get Professional jQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.