3.8. General Principles

As you may have noticed, Prototype applies a few general principles that users should be aware of, and that make Prototype code look slightly different from other JavaScript.

Interchangeable elements and ids

Elements and ids can be interchangeable in function calls, if a function expects a document id. It can normally take the element directly in place of the id.

Configuration via JSON

Options are typically passed to functions as JSON objects.

Loops are codes as higher-order functions

Loops are often replaced by Enumerations.

Higher-order combining forms are used

Prototype uses unusual combining forms, such as combining functions prior to their application.

Get Prototype and Scriptaculous: Taking the Pain out of JavaScript 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.