O'Reilly logo

Prototype and Scriptaculous: Taking the Pain out of JavaScript by Chris Angus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required