Skip to Content
Closure: The Definitive Guide
book

Closure: The Definitive Guide

by Michael Bolin
September 2010
Intermediate to advanced
592 pages
18h 30m
English
O'Reilly Media, Inc.
Content preview from Closure: The Definitive Guide

Chapter 3. Closure Library Primitives

As demonstrated in Chapter 1, the one JavaScript file used to bootstrap the rest of the Closure Library is base.js. This is where the root object, goog, is created, to which all other properties in the Closure Library are added. Because all of the functions defined in base.js are available to any JavaScript code that uses the Closure Library, they are, in a sense, primitives of the Library. This chapter is a comprehensive reference for these primitives.

In enumerating the API of base.js, this chapter also aims to explain how some high-level concepts are designed to work in the Closure Library, and to provide insight into the Library’s design. Each section is intended to introduce an idiom of the Library, and the subsections list the variables and functions in base.js that support that idiom.

Dependency Management

The “Hello World” example in Chapter 1 demonstrated that goog.provide() and goog.require() are used to establish dependency relationships in the Closure Library. This section discusses the mechanics of how these functions implement the dependency management system for the Library.

calcdeps.py

Unlike Java, in which multiple interdependent classes can be compiled together, JavaScript files cannot contain forward declarations due to the fact that JavaScript files are evaluated linearly as determined by <script> tag order in a web page. To produce an ordering without forward declarations, calcdeps.py uses goog.require() and goog.provide() calls ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Etudes for ClojureScript

Etudes for ClojureScript

J. David Eisenberg
The Hidden Cost of AI-Assisted Creativity

The Hidden Cost of AI-Assisted Creativity

Léonard Boussioux, Anil Doshi, Oliver Hauser, Kartik Hosanagar

Publisher Resources

ISBN: 9781449381882Errata Page