... class:
Object.extend(EvenArray .prototype, Enumerable);
Remember how Object.extend works—we’re taking each property on Enumerable and
copying it onto
EvenArray .prototype.
And we’re done. No, really. ... with
Object.extend. When using Prototype, you’ll find there is rarely a step three.
Summary
Playing with Enumerable methods is a good way to dip your toe into the Prototype pool.
You’...
... Up 107
Custom Events 108
The First Custom Event 109
Broadcasting Scores 109
Listening for Scores 110
Summary 111
■CHAPTER 6 Working with the DOM 113
About the DOM API 113
Node Genealogy 113
■CONTENTS ... Here) 91
Pre-DOM, Part 1 91
Pre-DOM, Part 2 92
Events: The Crash Course 94
Using Event#stopPropagation, Event#preventDefault,
and Event#stop
99
A Further Example 101
Events...
... both for creating Prototype and for inviting
me to be a part of Prototype Core. Other team members gave critical moral support:
Thomas Fuchs, Tobie Langel, Mislav Marohnic, and Justin Palmer.
Objects, ... KNOW ABOUT PROTOTYPE, JAVASCRIPT, AND THE DOM4
About the Technical Reviewer
After getting hooked on the Web in 1996 and spending several years pushing pixels and
bits for th...
... code both smaller and easier to read. Prototype uses
Object.extend all over
the place internally: extending built-ins, “mixing in” interfaces, and merging default
options with user-defined options.
CHAPTER ... rel
attribute.
These are just some of the complex selectors you can use in
$$. For more information
on what’s possible, consult the Prototype API reference online (
http://pro...
... we can also use that
function as a litmus test to let us know whether an item matches our needle. The next
four methods do just this.
Using Enumerable#detect
Enumerable#detect finds and returns ... NodeLists, and
various other groups of items. Nearly all your scripts will do some form of iteration over
an array. So why is iteration so bland in JavaScript?
Prototype sports a robust lib...
... single client using it. Responsiveness is good, and periodic client-server
communication is good—but these benefits will eventually clash with the practical
constraints of bandwidth and processing ... run automatically, thereby
saving the user the tedious task of manually reloading the page every time.
Let’s try it. Reload
index.html and run this command in the console:
new Ajax.Peri...
... we’re in PHP,
though, we’ll use associative arrays.
If you
’re using a different server-side language, don’t worry—JSON libraries exist for
practically ev
ery commonly used programming language. ... timestamp value by
600 and take the remainder. This will give us a value between 0 and 599.
First, we grab the timestamp. All we’re looking for is a number from 0 to 600 (telling
us where...
... THE DOM 115
custom events from anywhere in your code; you can also listen for custom events with
the same API that you’d use to listen for native browser events.
The First Custom Event
Prototype ... of words.
Prototype establishes a bridge between the DOM and the commonest use cases
of the typical developer. As a result, the code you write will be shorter and far more
readable.
Pro...
... FUNCTIONAL PROGRAMMING AND CLASS-BASED OOP164
var sumPlusTen = sum.curry(10);
typeof sumPlusTen; //-> "function"
sumPlusTen(5); //-> 15
sumPlusTen(); //-> 10
sumPlusTen(2, 3, 4); ... a function that expects parameters
a, b, and c by
giving it
a and b ahead of time—getting back a function that expects only c.
Confused yet? What I just said is much easier to express i...