100% found this document useful (2 votes)
21 views

Pro JavaScript Techniques 2nd Edition John Resig - The ebook in PDF/DOCX format is ready for download now

The document promotes the book 'Pro JavaScript Techniques 2nd Edition' by John Resig and offers links to download it and other recommended JavaScript-related ebooks. It discusses the evolution of JavaScript, highlighting its transition from a simple scripting language to a powerful programming tool, and the impact of modern browsers and libraries on its development. The content emphasizes the importance of understanding JavaScript's current state and its future directions for professional programmers.

Uploaded by

braahaacher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
21 views

Pro JavaScript Techniques 2nd Edition John Resig - The ebook in PDF/DOCX format is ready for download now

The document promotes the book 'Pro JavaScript Techniques 2nd Edition' by John Resig and offers links to download it and other recommended JavaScript-related ebooks. It discusses the evolution of JavaScript, highlighting its transition from a simple scripting language to a powerful programming tool, and the impact of modern browsers and libraries on its development. The content emphasizes the importance of understanding JavaScript's current state and its future directions for professional programmers.

Uploaded by

braahaacher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Visit ebookfinal.

com to download the full version and


explore more ebooks or textbooks

Pro JavaScript Techniques 2nd Edition John Resig

_____ Click the link below to download _____


https://ebookfinal.com/download/pro-javascript-
techniques-2nd-edition-john-resig/

Explore and download more ebooks or textbook at ebookfinal.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Pro JavaScript Design Patterns 1st Edition Ross Harmes

https://ebookfinal.com/download/pro-javascript-design-patterns-1st-
edition-ross-harmes/

JavaScript A Beginner s Guide Third Edition John Pollock

https://ebookfinal.com/download/javascript-a-beginner-s-guide-third-
edition-john-pollock/

Learning JavaScript 2nd Edition Shelley Powers

https://ebookfinal.com/download/learning-javascript-2nd-edition-
shelley-powers/

Object Oriented JavaScript 2nd Edition Stoyan Stefanov

https://ebookfinal.com/download/object-oriented-javascript-2nd-
edition-stoyan-stefanov/
Advanced Javascript 2E 2nd Edition Chuck Easttom

https://ebookfinal.com/download/advanced-javascript-2e-2nd-edition-
chuck-easttom/

Pro Puppet 2nd Edition Spencer Krum

https://ebookfinal.com/download/pro-puppet-2nd-edition-spencer-krum/

Jasmine JavaScript Testing 2nd Edition Test your


JavaScript applications efficiently using Jasmine and
React js Paulo Ragonha
https://ebookfinal.com/download/jasmine-javascript-testing-2nd-
edition-test-your-javascript-applications-efficiently-using-jasmine-
and-react-js-paulo-ragonha/

The Musician s Guide to Pro Tools 1st Edition John Keane

https://ebookfinal.com/download/the-musician-s-guide-to-pro-tools-1st-
edition-john-keane/

Learning jQuery 4th Edition Better interaction design and


web development with simple JavaScript techniques Jonathan
Chaffer
https://ebookfinal.com/download/learning-jquery-4th-edition-better-
interaction-design-and-web-development-with-simple-javascript-
techniques-jonathan-chaffer/
Pro JavaScript Techniques 2nd Edition John Resig
Digital Instant Download
Author(s): John Resig, Russ Ferguson, John Paxton
ISBN(s): 9781430263913, 1430263911
File Details: PDF, 3.66 MB
Year: 2015
Language: english
www.it-ebooks.info
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.

www.it-ebooks.info
Contents at a Glance

About the Authors�������������������������������������������������������������������������������������������������� xiii


About the Technical Reviewers�������������������������������������������������������������������������������xv
Acknowledgments�������������������������������������������������������������������������������������������������xvii


■Chapter 1: Professional JavaScript Techniques���������������������������������������������������� 1

■Chapter 2: Features, Functions, and Objects��������������������������������������������������������� 7

■Chapter 3: Creating Reusable Code��������������������������������������������������������������������� 23

■Chapter 4: Debugging JavaScript Code��������������������������������������������������������������� 39

■Chapter 5: The Document Object Model�������������������������������������������������������������� 49

■Chapter 6: Events������������������������������������������������������������������������������������������������ 73

■Chapter 7: JavaScript and Form Validation��������������������������������������������������������� 95

■Chapter 8: Introduction to Ajax������������������������������������������������������������������������� 107

■Chapter 9: Web Production Tools����������������������������������������������������������������������� 117

■Chapter 10: AngularJS and Testing������������������������������������������������������������������� 125

■Chapter 11: The Future of JavaScript���������������������������������������������������������������� 141

■Appendix A: DOM Reference������������������������������������������������������������������������������ 161

Index��������������������������������������������������������������������������������������������������������������������� 177

www.it-ebooks.info
Chapter 1

Professional JavaScript Techniques

Welcome to Pro JavaScript Techniques. This book provides an overview of the current state of JavaScript,
particularly as it applies to the professional programmer. Who is the professional programmer? Someone
who has a firm grasp of the basics of JavaScript (and probably several other languages). You are interested
in the breadth and depth of JavaScript. You want to look at the typical features like the Document Object
Model (DOM), but also learn about what’s going on with all this talk of Model-View-Controller (MVC) on the
client side. Updated APIs, new features and functionality, and creative applications of code are what you are
looking for here.
This is the second edition of this book. Much has changed since the first edition came out in 2006.
At that time, JavaScript was going through a somewhat painful transition from being a toy scripting language
to being a language that was useful and effective for several different tasks. It was, if you will, JavaScript’s
adolescence. Now, JavaScript is at the end of another transition: to continue the metaphor, from adolescence
to adulthood. JavaScript usage is nearly ubiquitous, with anywhere from 85 to 95 percent of websites,
depending on whose statistics you believe, having some JavaScript on their main page. Many people speak
of JavaScript as the most popular programming language in the world (in the number of people who use it
on a regular basis). But more important than mere usage are effectiveness and capability.
JavaScript has transitioned from a toy language (image rollovers! status bar text manipulations!) to
an effective, if limited tool (think of client-side form validation), to its current position as a broad-featured
programming language no longer limited to mere browsers. Programmers are writing JavaScript tools that
provide MVC functionality, which was long the domain of the server, as well as complex data visualizations,
template libraries, and more. The list goes on and on. Where in the past, designers would have relied on a
.NET or Java Swing client to provide a full-featured, rich interface to server-side data, we can now realize that
application in JavaScript with a browser. And, using Node.js, we have JavaScript’s own version of a virtual
machine, an executable that can run any number of different applications, all written in JavaScript and none
requiring a browser.
This chapter will describe how we got here and where we are going. It will look at the various
improvements in browser technology (and popularity) that have abetted the JavaScript Revolution. The state
of JavaScript itself needs inspection, as we want to know where we are before we look at where we are going.
Then, as we examine the chapters to come, you will see what the professional JavaScript programmer needs
to know to live up to his or her title.

How Did We Get Here?


As of the first edition of the book, Google Chrome and Mozilla Firefox were relatively new kids on the block.
Internet Explorer 6 and 7 ruled the roost, with version 8 gaining some popularity. Several factors combined
to jump-start JavaScript development.
For most of its life, JavaScript was dependent upon the browser. The browser is the runtime
environment for JavaScript, and a programmer’s access to JavaScript functionality was highly dependent

www.it-ebooks.info
Chapter 1 ■ Professional JavaScript Techniques

upon the make, model, and version of browser visiting said programmer’s website. By the mid-2000s, the
browser wars of the 90s had been easily won by Internet Explorer, and browser development stagnated.
Two browsers challenged this state of affairs: Mozilla Firefox and Google Chrome. Firefox was the
descendant of Netscape, one of the earliest web browsers. Chrome had Google’s backing, more than
enough to make it an instant player on the scene.
But both of these browsers made a few design decisions that facilitated the JavaScript revolution.
The first decision was to support the World Wide Web consortium’s implementation of various standards.
Whether dealing with the DOM, event handling, or Ajax, Chrome and Firefox generally followed the spec
and implemented it as well as possible. For programmers, this meant that we didn’t have to write separate
code for Firefox and Chrome. We were already used to writing separate code for IE and something else, so
having branching code in itself was not new. But making sure that the branching was not overly complex was
a welcome relief.
Speaking of standards, Firefox and Chrome also put in a lot of work with the European Computer
Manufacturer’s Association (ECMA, now styled Ecma). Ecma is the standards body that oversees JavaScript.
(To be technical, Ecma oversees the ECMAScript standard, since JavaScript is a trademark of Oracle and…
well, we don’t really care about those details, do we? We will use JavaScript to refer to the language and
ECMAScript to refer to the specification to which a JavaScript implementation adheres.) ECMAScript
standards had languished in much the same way as IE development. With the rise of real browser
competition, the ECMAScript standard was taken up again. ECMAScript version 5 (2009) codified many of
the changes that had been made in the ten years (!) since the previous version of the standard. The group
itself was also energized, with version 5.1 coming out in 2011. The future is provided for, with significant
work currently being done on both versions 6 and 7 of the standard.
To give credit where credit is due, Chrome pushed the updating of JavaScript as well. The Chrome
JavaScript engine, called V8, was a very important part of Chrome’s debut in 2008. The Chrome team built
an engine that was much faster than most JavaScript engines, and it has kept that goal at the top of the list
for subsequent versions. In fact, the V8 engine was so impressive that it became the core of Node.js, a
browser-independent JavaScript interpreter. Originally intended as a server that would use JavaScript
as its main application language, Node has become a flexible platform for running any number of
JavaScript-based applications.
Back to Chrome: the other major innovation Google introduced to the land of browsers was the concept
of the evergreen application. Instead of having to download a separate browser install for updates, Chrome’s
default is to automatically update the browser for you. While this approach is sometimes a pain in the
corporate world, it is a great boon to the noncorporate consumer surfer (also known as a person!). If you use
Chrome (and, for the last few years, Firefox), your browser is up-to-date, without your having to make any
effort. While Microsoft has done this for a long time in pushing security updates via Windows Update, it
does not introduce new features to Internet Explorer unless they are coupled to a new version of Windows.
To put it another way, updates to IE are slow in coming. Chrome and Firefox always have the latest and
greatest features, as well as being quite secure.
As Google pressed on with Chrome’s features, the other browser makers played catch-up. Sometimes
this came in sillier ways, such as when Firefox adapted Chrome’s version numbering. But it also resulted in
Mozilla and Microsoft taking a cold, hard look at JavaScript engines. Both browser makers have significantly
overhauled their JS engines over the last few years, and Chrome’s lead, while formidable, is no longer
insurmountable.
Finally, Microsoft has (mostly) thrown in the towel on its classic “embrace and extend” philosophy, at
least when it comes to JavaScript. With IE version 9, Microsoft implemented World Wide Web Consortium
(W3C) event handling and standardized its DOM interfaces as well as its Ajax API. For most of the standard
features of JavaScript, we no longer have to implement two versions of the same code! (Legacy code for
legacy browsers is still a bit of an issue, of course…)
It seems almost a panacea. JavaScript is faster than ever before. It is easier to write code for a variety
of different browsers. Standards documents both describe the real world and provide a useful roadmap to
features to come. And most of our browsers are fully up-to-date. So what do we need to worry about now,
and where are we going in the future?

www.it-ebooks.info
Chapter 1 ■ Professional JavaScript Techniques

Modern JavaScript
It has never been easier to develop serious applications with JavaScript. We have a clear, clean break with
the bad old days of separate code for multiple browsers, poor standards poorly implemented, and slow
JavaScript engines that were often an afterthought. Let’s take a look at the state of the modern JavaScript
environment. Specifically, we will look at two areas: the modern browser and the modern toolkit.
Modern JavaScript depends on the idea of the modern browser. What is the modern browser? Different
organizations describe it in different ways. Google says that their applications support the current and
previous major versions of browsers. (Fascinating, as Gmail still works on IE9, as far as we can tell!) In an
interesting article, the people behind the British Broadcasting Company (BBC) website revealed that they
define a modern browser as one that supports the following capabilities:
1. document.querySelector() / document.querySelectorAll()
2. window.addEventListener()
3. The Storage API (localStorage and sessionStorage)
jQuery, probably the most popular JavaScript library on the web, split its versions into the 1.x line,
which supports IE 6 and later, and the 2.x line, which supports “modern” browsers like IE 9 and later. And
make no mistake, IE is the dividing line between the modern and the ancient. The other two major browsers
are evergreen. And while Safari and Opera are not evergreen, they update on a faster schedule than IE and
don’t have nearly the market share it does.
So where is the borderline for the modern browser? Alas, the border seems to wander between Internet
Explorer versions 9 through 11. But IE 8 is definitely on the far side of browser history. It does not support
most of the features of ECMAScript 5. It does not include the API for W3C event handling. The list goes on
and on. So when we discuss modern browsers, we will refer to at least Internet Explorer 9. And our coverage
will not endeavor to support ancient browsers. Where relevant and simple, we will point out polyfills for
older versions of IE, but in general, our floor is Internet Explorer 9.

The Rise of Libraries


In addition to the modern browser, there is another important aspect of the current environment for
JavaScript we need to discuss: libraries. Over the past 8 years, there has been an explosion in the number
and variety of JavaScript libraries. There are more than 800,000 GitHub repositories for JavaScript; of these,
almost 900 have more than 1,000 stars. From its humble beginnings as collections of utility functions, the
JavaScript library ecosystem has evolved (somewhat chaotically) into a vast landscape of possibilities.
How does this affect us as JavaScript developers? Well, of course, there is the model of “library as
expansion,” where a library provides additional functionality. Think of the MVC libraries like Backbone
and Angular (which we will be looking at in a later chapter), or the data visualization libraries like d3 or
Highcharts. But JavaScript is in an interesting position, as libraries can also provide a level interface to
features that are standard on some browsers but not on others.
For a long time, the standard example of a variably implemented feature in JavaScript was event
handling. Internet Explorer had its own event-handling API. Other browsers generally followed the W3C’s
API. Various libraries provided unified implementations for event handling, including the best of both
worlds. Some of these libraries stood alone, but the successful ones also normalized functionality for Ajax,
the DOM, and a number of other features that were differently implemented across browsers.
The most popular of these libraries has been jQuery. Since its inception, jQuery has been the go-to
library for using new JavaScript features without worrying about the browser’s support for those features.
So instead of using IE’s event handling or the W3C’s, you could simply use jQuery’s .on() function, which
wrapped around the variance, providing a unified interface. Several other libraries provided similar
functionality: Dojo, Ext JS, Prototype, YUI, MooTools, and so on. These toolkit libraries aimed to standardize
APIs for developers.

www.it-ebooks.info
Chapter 1 ■ Professional JavaScript Techniques

The standardization goes further than providing simple branching code. These libraries often
ameliorate buggy implementations. The official API for a function may not change much between versions,
but there will be bugs; sometimes those bugs will be fixed, sometimes not, and sometimes the fixes will
introduce new bugs. Where libraries could fix or work around these bugs, they did. For example, jQuery 1.11
contains more than a half-dozen fixes for problems with the event-handling API.
Some libraries (jQuery in particular) also provided new or different interpretations of certain
capabilities. The jQuery selector function, the core of the library, predates the now-standard
querySelector() and querySelectorAll() functions, and it was a driver for including those functions in
JavaScript. Other libraries provide access to functionality despite very different underlying implementations.
Later in the book, we will look at Ajax’s new Cross Origin Resource Sharing (CORS) protocol, which allows
for Ajax requests to servers other than the one that originally served the page. Some libraries have already
implemented a version of this that uses CORS but falls back to JSON with padding (JSON-P) where needed.
Because of their utility, some libraries have become part of a professional JavaScript programmer’s
standard development toolkit. Their features may not be standardized into JavaScript (yet), but they are an
accumulation of knowledge and functionality that simply makes it easier to realize designs quickly. In recent
years, though, you could get quite a few hits to your blog by asking whether jQuery (or another library) was
really necessary for development on a modern browser. Consider the BBC’s requirements; you can certainly
realize a large degree of jQuery-like functionality if you have those three methods available to you. But
jQuery also includes a simplified yet expanded DOM interface, it handles bugs for a variety of different edge
cases, and if you need support for IE 8 or earlier, jQuery is your major option. Accordingly, the professional
JavaScript programmer must look at the requirements for a project and consider whether it pays to risk
reinventing the wheel that jQuery (or another similar library) provides.

More Than a Note about Mobile


In older JavaScript and web development books, you would reliably see a section, maybe a whole chapter,
on what to do about mobile browsing. Mobile browsing was a small enough share of total browsing, and the
market was so fractured, that it seemed only specialists would be interested in mobile development. That’s
not the case anymore. Since the first edition of this book, mobile web browsing has exploded, and it is a
very different beast from desktop development. Consider some statistics: according to a variety of sources,
mobile browsing represents between 20 and 30 percent of all browsing. By the time you are reading this, it
may well represent more, as it has consistently increased since the debut of the iPhone. Speaking of which,
well over 40 percent of mobile browsing is done with iOS Safari, although Android’s browser and Chrome for
Android are gaining ground (and may have overtaken Safari, depending on whose stats you believe). Safari
on iOS is not the same as Safari on the desktop, and the same goes for Android Chrome vs. desktop Chrome
and mobile Firefox vs. desktop Firefox. Mobile is mainstream.
The browsers on mobile devices provide a new set of challenges and opportunities. Mobile devices are
often more limited than desktops (though that’s another gap that is rapidly closing). Conversely, mobile
devices offer new features (swipe events, more accurate geolocation, and so on) and new interaction idioms
(using the hand instead of the mouse, swiping for scrolling). Depending on your development requirements,
you may have to build an app that looks good on mobile as well as the desktop, or reimplement existing
functionality for a mobile platform.
The JavaScript landscape has changed extensively over the last few years. Despite some standardization
of APIs, there are also many new challenges. How will this affect us as professional JavaScript programmers?

www.it-ebooks.info
Chapter 1 ■ Professional JavaScript Techniques

Where Do We Go from Here?


We should set down some standards for ourselves. We have already set one: IE9 as the floor of the modern
browser experience. The other browsers are evergreen, and not to worry about. What about mobile, then?
While the issue is complex, iOS 6 and Android 4.1 (Jelly Bean) will, in general, serve as our floors. Mobile
computing updates faster and more frequently than desktops do, so we are confident in using these more
recent versions of mobile operating systems.
That said, let us digress for a moment to discuss not browser versions, operating systems, or platforms,
but your audience. While we can quote statistics all day long, the valuable statistics tell you about your
audience, not the audience in general. Perhaps you are designing for your employer, who has standardized
on IE 10. Or maybe your idea for an application depends heavily on features that only Chrome provides.
Or maybe there isn’t even a desktop version, but you’re aiming for a roll-out to iPads and Android tablets.
Consider your target audience. This book is written to be broadly applicable, and your application may be as
well. But it would be folly to spend time worrying about bugs in IE9 for that previously mentioned tablet-
only application, wouldn’t it? Now, back to our standards.
For screenshots and testing, this book will generally prefer Google Chrome. Occasionally, we will
demonstrate code on Firefox or Internet Explorer where it is relevant. Chrome, for developers, is the gold
standard—not necessarily in user-friendliness, but certainly in the information exposed to the programmer.
In a later chapter, we will look at the various developer tools available, scrutinizing not only Chrome, but
Firefox (with and without Firebug) and IE as well.
As a standard library, we will refer to jQuery. There are many alternatives, of course, but jQuery wins for
two reasons: first, it is the most popular general-use JavaScript library on the web. Second, at least one of the
authors (John Resig) has a little bit of history with jQuery, which predisposed the other author (John Paxton)
to concede the point of working with it. In updating this book, we have replaced many of the techniques
from the previous version with jQuery’s library of functionality. In these cases, we are disinclined to reinvent
the wheel. As needed, we will refer to the appropriate jQuery functionality. We will, of course, discuss new
and exciting techniques, as well!
JavaScript IDEs have updated significantly in the last few years, driven by JavaScript’s own rise. The
possibilities are too numerous to list here, but there are a few applications of note. John Resig uses a highly
customized version of vim for his development environment. John Paxton is a little bit lazier, and has elected
to use JetBrains’ excellent WebStorm (http://www.jetbrains.com/webstorm/) as his IDE. Adobe offers the
open source, free Brackets IDE (http://brackets.io/), currently at version 1.3. Eclipse is also available, and
many people have reported positive results by customizing SublimeText or Emacs to do their bidding. As
always, use what you feel most comfortable with.
There are other tools that can assist in JavaScript development. Rather than list them here, we will
dedicate a chapter to them later in the book. Which means it’s a good time to give an outline of what’s
to come.

Coming Up Next
Starting with Chapter 2, we will look at the latest and greatest in the JavaScript language. This means looking
at new features like those available through the Object type, but also reexamining some older concepts like
references, functions, scope, and closures. We will lump all of this under the heading of Features, Functions,
and Objects, but it covers a bit more than that.
Chapter 3 discusses Creating Reusable Code. Chapter 2 skips over one of the biggest new features of
JavaScript, the Object.create() method, and its implications for object-oriented JavaScript code. So in this
chapter we will spend time with Object.create(), functional constructors, prototypes, and object-oriented
concepts as implemented in JavaScript.
Having spent two chapters developing code, we should start thinking about how to manage it. Chapter 4
shows you tools for Debugging JavaScript Code. We start by examining browsers and their developer tools.

www.it-ebooks.info
Chapter 1 ■ Professional JavaScript Techniques

Chapter 5 begins a sequence discussing some high-usage areas of JavaScript functionality. Here we look
at the Document Object Model. The DOM API has increased in complexity and has not really become more
straightforward since the last edition. But there are new features that we should familiarize ourselves with.
In Chapter 6, we attempt to master Events. The big news here is the standardization of the events API
along the lines of the W3C style. This provides us the opportunity to move away from utility libraries and
finally go deep into the events API without worrying about large variations between browsers.
One of the first non-toy applications for JavaScript was client-side form validation. Amazingly, it took
browser makers over a decade to think about adding functionality to form validation beyond capturing the
submit event. When looking in Chapter 7 at JavaScript and Form Validation, we will discover that there is a
whole new set of functionality for form validation provided by both HTML and JavaScript.
Everyone who develops with JavaScript has spent some time Introduction to Ajax. With the
introduction of Cross-Origin Resource Sharing (CORS), Ajax functionality has finally moved past the silliest
of its restrictions.
Command line tools like Yeoman, Bower, Git and Grunt are covered in Web Production Tools.
These tools will show us how to quickly add all the files and folders needed. This way we can focus on
development.
Chapter 10 covers AngularJS and Testing. Using the knowledge gained in the previous chapter, we now
start to look at what makes Angular work and how to implement both unit and end to end testing.
Last, Chapter 11 discusses the Future of JavaScript. ECMAScript 6 will be settled, more or less, by the
time this book goes to press. ECMAScript 7 is in active development. Beyond the basics of where JavaScript
is going, we will look at what features you can use right now.

Summary
We spent a lot of this chapter on everything around JavaScript: the platform(s), the history, the IDEs, and so on.
We believe that history informs the present. We wanted to explain where we were, and how we got here, to
help you understand why JavaScript is where it is, and is what it is, today. Of course, we plan to spend the
bulk of this book talking about how JavaScript works, particularly for the professional programmer. We feel
quite strongly that this book covers the techniques and APIs that every professional JavaScript programmer
should be familiar with. So without further ado…

www.it-ebooks.info
Chapter 2

Features, Functions, and Objects

Objects are the fundamental units of JavaScript. Virtually everything in JavaScript is an object and interacts
on an object-oriented level. To build up this solid object-oriented language, JavaScript includes an arsenal of
features that make it unique in both its foundation and its capabilities.
This chapter covers some of the most important aspects of the JavaScript language, such as references,
scope, closures, and context. These are not necessarily the cornerstones of the language, but the elegant
arches, which both support and refine JavaScript. We will delve into the tools available for working with
objects as data structures. A dive into the nature of object-oriented JavaScript follows, including a discussion
of classes vs. prototypes. Finally, the chapter explores the use of object-oriented JavaScript, including exactly
how objects behave and how to create new ones. This is quite possibly the most important chapter in this
book if taken to heart, as it will completely change the way you look at JavaScript as a language.

Language Features
JavaScript has a number of features that are fundamental to making the language what it is. There are very
few other languages like it. We find the combination of features to fit just right, contributing to a deceptively
powerful language.

References and Values


JavaScript variables hold data in one of two ways: by copies and references. Anything that is a primitive value
is copied into a variable. Primitives are strings, numbers, Booleans, null, and undefined. The most important
characteristic of primitives is that they are assigned, copied, and passed to and returned from functions
by value.
The rest of JavaScript relies on references. Any variable that does not hold one of the aforementioned
primitive values holds a reference to an object. A reference is a pointer to the location in memory of
an object (or array, or date, or what-have-you). The actual object (array, date, or whatever) is called the
referent. This is an incredibly powerful feature, present in many languages. It allows for certain efficiencies:
two (or more!) variables do not have their own copies of an object; they simply refer to the same object.
Updates to the referent made via one reference are reflected in the other reference. By maintaining sets of
references to objects, JavaScript affords you much more flexibility. An example of this is shown in Listing 2-1,
where two variables point to the same object, and the modification of the object’s contents via one reference
is reflected in the other reference.

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-1. Example of Multiple Variables Referring to a Single Object


// Set obj to an empty object
// (Using {} is shorter than 'new Object()')
var obj = {};

// objRef now refers to the other object


var refToObj = obj;

// Modify a property in the original object


obj.oneProperty = true;

// We now see that the change is represented in both variables


// (Since they both refer to the same object)
console.log( obj.oneProperty === refToObj.oneProperty );

// This change goes both ways, since obj and refToObj are both references
refToObj.anotherProperty = 1;
console.log( obj.anotherProperty === refToObj.anotherProperty );

Objects have two features: properties and methods. These are often referred to collectively as the
members of an object. Properties contain the data of an object. Properties can be primitives or objects
themselves. Methods are functions that act upon the data of an object. In some discussions of JavaScript,
methods are included in the set of properties. But the distinction is often useful.
Self-modifying objects are very rare in JavaScript. Let’s look at one popular instance where this occurs.
The Array object is able to add additional items to itself using the push method. Since, at the core of an Array
object, the values are stored as object properties, the result is a situation similar to that shown in Listing 2-1,
where an object becomes globally modified (resulting in multiple variables’ contents being simultaneously
changed). An example of this situation can be found in Listing 2-2.

Listing 2-2. Example of a Self-Modifying Object


// Create an array of items
// (Similar to 2-1, using [] is shorter than 'new Array()')
var items = [ 'one', 'two', 'three' ];

// Create a reference to the array of items


var itemsRef = items;

// Add an item to the original array


items.push( 'four' );

// The length of each array should be the same,


// since they both point to the same array object
console.log( items.length == itemsRef.length );

It’s important to remember that references point only to the referent object, not to another reference.
In Perl, for example, it’s possible to have a reference point to another variable that also is a reference. In
JavaScript, however, it traverses down the reference chain and only points to the core object. An example of
this situation can be seen in Listing 2-3, where the physical object is changed but the reference continues to
point back to the old object.

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-3. Changing the Reference of an Object While Maintaining Integrity


// Set items to an array (object) of strings
var items = [ 'one', 'two', 'three' ];
// Set itemsRef to a reference to items
var itemsRef = items;

// Set items to equal a new object


items = [ 'new', 'array' ];

// items and itemsRef now point to different objects.


// items points to [ 'new', 'array' ]
// itemsRef points to [ 'one', 'two', 'three' ]
console.log( items !== itemsRef );

Finally, let’s look at a strange instance that you might think would involve references but does not.
When performing string concatenation, the result is always a new string object rather than a modified
version of the original string. Because strings (like numbers and Booleans) are primitives, they are not
actually referents, and the variables that contain them are not references. This can be seen in Listing 2-4.

Listing 2-4. Example of Object Modification Resulting in a New Object, Not a Self-Modified Object
// Set item equal to a new string object
var item = 'test';

// itemRef now refers to the same string object


var itemRef = item;

// Concatenate some new text onto the string object


// NOTE: This creates a new object and does not modify
// the original object.
item += 'ing';

// The values of item and itemRef are NOT equal, as a whole


// new string object has been created
console.log( item != itemRef );

Strings are often particularly confusing because they act like objects. You can create instances of strings
via a call to new String. Strings have properties like length. Strings also have methods like indexOf and
toUpperCase. But when interacting with variables or functions, strings are very much primitives.
References can be a tricky subject to wrap your mind around, if you are new to them. Nonetheless,
understanding how references work is paramount to writing good, clean JavaScript code. In the next couple
of sections we’re going to look at features that aren’t necessarily new or exciting but are important for writing
good, clean code.

Scope
Scope is a tricky feature of JavaScript. Most programming languages have some form of scope; the
differences lie in the duration of that scope. There are only two scopes in JavaScript: functional scope and
global scope. This is deceptively simple. Functions have their own scope, but blocks (such as while, if, and
for statements) do not. This may seem strange if you are coming from a block-scoped language. Listing 2-5
shows an example of the implications of function-scoped code.

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-5. Example of How the Variable Scope in JavaScript Works


// Set a global variable, foo, equal to test
var foo = 'test';

// Within an if block
if ( true ) {
// Set foo equal to 'new test'
// NOTE: This still belongs to the global scope!
var foo = 'new test';
}

// As we can see here, as foo is now equal to 'new test'


console.log( foo === 'new test' );

// Create a function that will modify the variable foo


function test() {
var foo = 'old test';
}

// However, when called, 'foo' remains within the scope


// of the function
test();

// Which is confirmed, as foo is still equal to 'new test'


console.log( foo === 'new test' );

You’ll notice that in Listing 2-5, the variables are within the global scope. All globally scoped variables
are actually visible as properties of the window object in browser-based JavaScript. In other environments,
there will be a global context to which all globally-scoped variables belong.
In Listing 2-6 a value is assigned to a variable, foo, within the scope of the test() function. However,
nowhere in Listing 2-6 is the scope of the variable actually declared (using var foo). When the foo variable
isn’t explicitly scoped, it will become defined globally, even though it is only intended to be used within the
context of the function.

Listing 2-6. Example of Implicit Globally Scoped Variable Declaration


// A function in which the value of foo is set
function test() {
foo = 'test';
}

// Call the function to set the value of foo


test();

// We see that foo is now globally scoped


console.log( window.foo === 'test' );

10

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

JavaScript’s scoping is often a source of confusion. If you are coming from a block-scoped language, this
confusion can lead to accidentally global variables, as shown here. Often, this confusion is compounded
by imprecise usage of the var keyword. For simplicity’s sake, the pro JavaScript programmer should always
initialize variables with var, regardless of scope. This way, your variables will have the scope you expected,
and you can avoid accidental globals.
When declaring variables within a function, be aware of the issue of hoisting. Any variable declared
within a function has its declaration (not the value it is initialized with) hoisted to the top of the scope.
JavaScript does this to ensure that the variable’s name is available throughout the scope.
Especially when we combine scope with the concept of context and closures, discussed in the next two
sections, JavaScript reveals itself as a powerful scripting language.

Context
Your code will always have some form of context (a scope within which the code is operating). Context can
be a powerful tool and is essential for object-oriented code. It is a common feature of other languages, but
JavaScript, as is often the case, has a subtly different take on it.
You access context through the variable this, which will always refer to the context that the code is running
inside. Recall that global objects are actually properties of the window object. This means that even in a global
context, this will still refer to an object. Listing 2-7 shows some simple examples of working with context.

Listing 2-7. Examples of Using Functions Within Context and Then Switching Context to Another Variable
function setFoo(fooInput) {
this.foo = fooInput;
}

var foo = 5;
console.log( 'foo at the window level is set to: ' + foo );

var obj = {
foo : 10
};

console.log( 'foo inside of obj is set to: ' + obj.foo );

// This will change window-level foo


setFoo( 15 );
console.log( 'foo at the window level is now set to: ' + foo );

// This will change the foo inside the object


obj.setFoo = setFoo;
obj.setFoo( 20 );
console.log( 'foo inside of obj is now set to: ' + obj.foo );

In Listing 2-7, our setFoo function looks a bit odd. We do not typically use this inside a generic utility
function. Knowing that we were eventually going to attach setFoo to obj, we used this so we could access
the context of obj. However, this approach is not strictly necessary. JavaScript has two methods that allow
you to run a function in an arbitrary, specified context. Listing 2-8 shows the two methods, call and apply,
that can be used to achieve just that.

11

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-8. Examples of Changing the Context of Functions


// A simple function that sets the color style of its context
function changeColor( color ) {
this.style.color = color;
}

// Calling it on the window object, which fails, since it doesn't


// have a style object
changeColor('white' );

// Create a new div element, which will have a style object


var main = document.createElement('div');

// Set its color to black, using the call method


// The call method sets the context with the first argument
// and passes all the other arguments as arguments to the function
changeColor.call( main, 'black' );

//Check results using console.log


//The output should say 'black'
console.log(main.style.color);

// A function that sets the color on the body element


function setBodyColor() {
// The apply method sets the context to the body element
// with the first argument, and the second argument is an array
// of arguments that gets passed to the function
changeColor.apply( document.body, arguments );
}

// Set the background color of the body to black

setBodyColor('black' );

While the usefulness of context may not be immediately apparent, it will become clearer when we look
at object orientation soon.

Closures
Closures are a means through which an inner function can refer to the variables present in its outer
enclosing function after its parent functions have already terminated. That’s the technical definition,
anyway. Perhaps it is more useful to think of closures tied to contexts. Up to this point, when we have
defined an object literal, that object was open for modification. We have seen that we can add properties and
functions to the object at any time. But what if we wanted a context that was locked? A context that “saved”
values as defaults. What about a context that could not be accessed without the API we provide? This is what
a closure provides: a context that is accessible only in the manner we choose.
This topic can be very powerful and very complex. We highly recommend referring to the sites
mentioned at the end of this section, as they have some excellent information about closures.
Let’s begin by looking at two simple examples of closures, shown in Listing 2-9.

12

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-9. Two Examples of How Closures Can Improve the Clarity of Your Code
// Find the element with an ID of 'main'
var obj = document.getElementById('main');

// Change its border styling


obj.style.border = '1px solid red';

// Initialize a callback that will occur in one second


setTimeout(function(){
// Which will hide the object
obj.style.display = 'none';
}, 1000);

// A generic function for displaying a delayed alert message


function delayedAlert( msg, time ) {
// Initialize an enclosed callback
setTimeout(function(){
// Which utilizes the msg passed in from the enclosing function
console.log( msg );
}, time );
}
// Call the delayedAlert function with two arguments
delayedAlert('Welcome!', 2000 );

The first function call to setTimeout shows an instance where new JavaScript developers often have
problems. It’s not uncommon to see code like this in a new developer’s program:

setTimeout('otherFunction()', 1000);

or even...

setTimeout('otherFunction(' + num + ',' + num2 + ')', 1000);

In both examples, the functions being called are expressed as strings. This can cause problems with the
minification process when you are about to move your code into production. By using closures, you can call
functions, use variables, and pass parameters as originally intended.
Using the concept of closures, it’s entirely possible to circumnavigate this mess of code. The first
example in Listing 2-9 is simple; there is a setTimeout callback being called 1,000 milliseconds after it is first
called, but still referring to the obj variable (which is defined globally as the element with an ID of main). The
second function defined, delayedAlert, shows a solution to the setTimeout mess that occurs, along with the
ability to have closures within function scope.
You should find that when using simple closures such as these in your code, the clarity of what you’re
writing increases instead of turning into a syntactical soup.
Let’s look at a fun side effect of what’s possible with closures. In some functional programming
languages, there’s the concept of currying, a way to prefill a number of arguments to a function, creating a
new, simpler function. Listing 2-10 has a simple example of currying, creating a new function that prefills an
argument to another function.

13

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-10. Example of Function Currying Using Closures


// A function that generates a new function for adding numbers
function addGenerator( num ) {

// Return a simple function for adding two numbers


// with the first number borrowed from the generator
return function( toAdd ) {
return num + toAdd
};

}
// addFive now contains a function that takes one argument,
// adds five to it, and returns the resulting number
var addFive = addGenerator( 5 );

// We can see here that the result of the addFive function is 9,


// when passed an argument of 4
console.log( addFive( 4 ) == 9 );

There’s another common JavaScript-coding problem that closures can solve. New JavaScript developers
often accidentally leave a lot of extra variables sitting in the global scope. This is generally considered bad
practice, as those extra variables could quietly interfere with other libraries, causing confusing problems
to occur. Using a self-executing anonymous function, you can essentially hide all normally global variables
from being seen by other code, as shown in Listing 2-11.

Listing 2-11. Example of Using Anonymous Functions to Hide Variables from the Global Scope
// Create a new anonymous function, to use as a wrapper
(function(){
// The variable that would normally be global
var msg = 'Thanks for visiting! ';

// Binding a new function to a global object


window.onload = function(){
// Which uses the 'hidden' variable
console.log( msg );
};

// Close off the anonymous function and execute it


})();

Finally, let’s look at one problem that occurs with closures. Remember that a closure allows you to
reference variables that exist within the parent function. However, it does not provide the value of the variable
at the time it is created; it provides the last value of the variable within the parent function. You’ll most
commonly see this occur during a for loop. There is one variable being used as the iterator (i). Inside the
for loop, new functions are being created that utilize the closure to reference the iterator again. The problem
is that by the time the new closured functions are called, they will reference the last value of the iterator (that
is, the last position in an array), not the value that you would expect. Listing 2-12 shows an example of using
anonymous functions to induce scope, to create an instance where expected closure is possible.

14

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-12. Example of Using Anonymous Functions to Induce the Scope Needed to Create Multiple
Closure-Using Functions
// An element with an ID of main
var obj = document.getElementById('main');

// An array of items to bind to


var items = ['click', 'keypress' ];

// Iterate through each of the items


for ( var i = 0; i < items.length; i++ ) {
// Use a self-executed anonymous function to induce scope
(function(){
// Remember the value within this scope
       // Each 'item' is unique.
      //Not relying on variables created in the parent context.
var item = items[i];
// Bind a function to the element
obj['on' + item ] = function() {
// item refers to a parent variable that has been successfully
// scoped within the context of this for loop
console.log('Thanks for your ' + item );
};
})();
}

We will return to closures in our section on object-oriented code, where they will help us to implement
private properties.
The concept of closures is not a simple one to grasp; it took us a lot of time and effort to truly wrap
our minds around how powerful closures are. Luckily, there are some excellent resources explaining how
closures work in JavaScript: “JavaScript Closures” by Richard Cornford, at http://jibbering.com/faq/faq_
notes/closures.html, and another explanation at the Mozilla Developer Network, https://developer.
mozilla.org/en-US/docs/Web/JavaScript/Closures.

Function Overloading and Type-Checking


A common feature in other object-oriented languages is the ability to overload functions to perform different
behaviors depending on the type or number of arguments passed in. While this ability isn’t a language
feature in JavaScript, we can use existing capabilities to implement overloading of functions.
Our overloaded functions need to know two things: how many arguments have been passed in and
what type of arguments have been passed. Let’s start by looking at the number of arguments provided.
Inside every function in JavaScript there exists a contextual variable named arguments that acts as an
array-like object containing all the, well, arguments passed into the function. The arguments object isn’t a
true array; it does not share a prototype with Array, and it does not have array-processing functions like push
or indexOf. It does have positional array access (for example, arguments[2] returns the third argument), and
there is a length property. There are two examples of this in Listing 2-13.

15

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

Listing 2-13. Two Examples of Function Overloading in JavaScript


// A simple function for sending a message
function sendMessage( msg, obj ) {
// If both a message and an object are provided
if ( arguments.length === 2 ) {
// Send the message to the object
// (Assumes that obj has a log property!)
obj.log( msg );
} else {
// Otherwise, assume that only a message was provided
// So just display the default error message
console.log( msg );
}
}

// Both of these function calls work


sendMessage( 'Hello, World!' );
sendMessage( 'How are you?', console );

You may wonder if there is a way to have the full functionality of an array available to the arguments
object. It is not possible with arguments itself, but it is possible to create a copy of arguments that is an array.
By invoking the slice method from the Array prototype, we can quickly copy the arguments object into an
array, as in Listing 2-14.

Listing 2-14. Converting Arguments to an Array


function aFunction(x, y, z) {
var argsArray = Array.prototype.slice.call( arguments, 0 );
console.log( 'The last argument is: ' + argsArray.pop() );
}

// Will output 'The last argument is 3'.


aFunction( 1, 2, 3 );

We will learn more about the prototype property very soon. For the moment, suffice it to say that the
prototype allows us to access object methods in a static manner.
What if the message were not defined? We need to be able to check not just for the presence of an
argument, but also its absence. We can take advantage of the fact that any argument that isn’t provided has
a value of undefined. Listing 2-15 shows a simple function for displaying an error message and providing
a default message if a particular argument is not provided. (Note that we must use typeof here, because
otherwise, an argument with the literal string “undefined” would indicate an error.)

Listing 2-15. Displaying an Error Message and a Default Message


function displayError( msg ) {
// Check and make sure that msg is not undefined
if ( typeof msg === 'undefined' ) {
// If it is, set a default message
msg = 'An error occurred.';
}

16

www.it-ebooks.info
Chapter 2 ■ Features, Functions, and Objects

// Display the message


console.log( msg );
}

displayError();

The use of the typeof statement helps to lead us into the topic of type-checking. Because JavaScript is a
dynamically typed language, this proves to be a very useful and important topic. There are a number of ways
to check the type of a variable; we’re going to look at two that are particularly useful.
The first way of checking the type of an object is by using the obvious-sounding typeof operator. This
utility gives us a string name representing the type of the contents of a variable. An example of this method
can be seen in Listing 2-16.

Listing 2-16. Example of Using typeof to Determine the Type of an Object


var num = '50';
var arr = 'apples,oranges,pears';

// Check to see if our number is actually a string


if ( typeof num === 'string' ) {
// If it is, then parse a number out of it
num = parseInt( num );
}

// Check to see if our array is actually a string


if ( typeof arr == 'string' ) {
// If that's the case, make an array, splitting on commas
arr = arr.split( ',' );
}

The advantage of typeof is that you do not have to know what the actual type of the tested variable is.
This would be the perfect solution except that for variables of type Object or Array, or a custom object such
as User, typeof only returns “object”, making it hard to differentiate between specific object types. The next
two ways to figure out the type of a variable require you to test against a specific existing type.
The second way to check the type of an object is to use the instanceof operator. This operator checks
the left operand against the constructor of the right operand, which may sound a bit more complex than it
actually is! Take a look at Listing 2-17, showing an example of using instanceof.

Listing 2-17. Example of Using instanceof


var today = new Date();
var re = /[a-z]+/i;

// These don't give us enough details


console.log('typeof today: ' + typeof today);
console.log('typeof re: ' + typeof re);

// Let's find out if the variables are of a more specific type


if (today instanceof Date) {
console.log('today is an instance of a Date.');
}

17

www.it-ebooks.info
Discovering Diverse Content Through
Random Scribd Documents
haren lateren bloei en welvaart, werd het Fort Sommelsdijk aan de
samenvloeiing van de Commewijne en de Cottica aangelegd, en werd
een einde gemaakt aan de herhaalde invallen der Indianen, die hij in
1684 tot den vrede dwong. Meer dan eens, zegt J. R. Thomson, in zijn
Overzicht der Geschiedenis van Suriname, trok hij aan het hoofd van
een geringe krijgsmacht tegen de vijandige Indianen op. Op zijn
tweeden tocht ging hij met drie vaartuigen over zee naar de
Coppename en drong hij het binnenland in, waarbij vele Indianen
gedood of gevangen werden genomen en ettelijke dorpen in de asch
werden gelegd.

Reeds vóór zijn komst, onder het Engelsche Bestuur, waren vele
slaven wegens de mishandelingen, die zij van hun blanke meesters
hadden te verduren, naar de bosschen gevlucht. Van Sommelsdijk
sloot in genoemd jaar ook met de Boschnegers van de Coppename
vrede.

Ook aan de voortdurende oorlogen, die verschillende


Indianenstammen, ook in het gebied van Guyana, hebben gevoerd,
kwam langzamerhand een einde. Vooral waren het de strijdlustige
Caraïben, die de meer vreedzame Arowakken voortdurend beoorloogd
hebben. Toch kwam het wel eens voor, dat, wanneer
gemeenschappelijke belangen in het spel waren, beide stammen zich
vereenigden, om gezamenlijk ten strijde te trekken.

Het besluit tot zulk een gemeenschappelijken strijd woonde o.a. een
der eerste missionarissen der Moravische [62]Broedergemeente
(Herrnhuttergemeente) bij, die in April 1745 aan de Corantijn kwam. Er
werd toen door de Caraïben en Arowakken aldaar een groote raad
inhouden, waarbij de voornaamste hoofdmannen (kapiteins)
tegenwoordig waren en waarop besloten werd, tegen de Spaansche
Indianen van het Orinoco-gebied op te trekken. In 18–20 vaartuigen
voeren zij naar de Orinoco en zij brachten 14 dagen op het water en 8
dagen op het land door. Eindelijk bereikten zij de vijandelijke kampen.
Aanvankelijk gedroegen zij zich als vrienden, hun allerlei ruilmiddelen
aanbiedend, maar plotseling overvielen zij hen, doodden zij de mannen
en namen zij de vrouwen en kinderen als gevangenen mede. Iedere
overwinnaar nam een verslagen vijand, sneedt hem het vleesch af, dat
in het eerstvolgende nachtkwartier geroosterd en opgegeten werd.

Deze geschiedkundige herinnering uit deugdelijken bron doet ons veel


denken aan de Legende van Mapajawari of de Uitroeiing der
Menscheneters, die wij onder No. 47 van dezen bundel opnemen.

Ook aan de Indiaansche broederoorlogen, die zooveel tot den


achteruitgang der Indianenbevolking hebben bijgedragen, kwam een
einde. In „Einde van den Indiaanschen broederoorlog” (No. 45) wordt
van het laatste dezer gevechten verteld.

Uit de geschiedenis der Zuid-Amerikaansche Indianen zijn evenals uit


die der Noord-Amerikaansche oorspronkelijke bevolking ook
voorbeelden bekend van de algeheele verdelging van stammen, die
eertijds een belangrijke rol hebben gespeeld. Hier mag o.a. herinnerd
worden aan de dappere Aturiërs door menschen-etende Caraïben,
waarvan, naar de groote natuuronderzoeker Alexander von
Humboldt ons in zijn meesterwerk „Ansichten der Natur” heeft
medegedeeld, nog destijds [63]onder de Guareca-Indianen de
overlevering gewaagde.

Onder het vermaarde rotsgewelf van Aturuipe, aan den rechteroever


van de Boven-Orinoco, ontdekte de onderzoekingsreiziger in het begin
der vorige eeuw het graf van den verdelgden volksstam. Ongeveer 600
goed bewaarde geraamten werden in even zoovele korven, zg.
mapires, gevlochten uit de stelen van palmbladen van verschillende
grootten, al naar den leeftijd der dooden, bewaard gevonden. Volgens
de bedoelde overlevering moeten de Aturiërs, door de Caraïben in het
nauw gebracht, zich op de klippen der hier door den stroom gevormde
watervallen gered hebben en in dit treurig toevluchtsoord ten onder zijn
gegaan. Volgens Von Humboldt moet de laatste familie der Aturiërs
eerst laat zijn uitgestorven, want te Maypures leefde in Humboldts tijd
nog een oude papegaai, van welke de inboorlingen beweerden, dat zij
hem daardoor niet verstaan konden, omdat hij de taal der Aturiërs
sprak. Von Humboldts vriend, de bekende geschiedvorscher Prof.
Ernst Curtius, heeft op dezen papegaai een treffend gedicht
vervaardigd, dat ik hier in de Nederlandsche vertaling van Dr. E. M.
Beima, die van bedoeld werk een Nederlandsche uitgave bezorgde, 25
in zijn geheel overneem. De trochaeus, de versvoet met de lange en
korte syllabe, die voor gedichten van plechtigen inhoud wordt
gebezigd, heeft de vertaler van den dichter overgenomen.

In de verre en woeste streken


Van den Orinoco-stroom,
Zit een papegaai te treuren,
Als versteend, zoo koud en loom

Schuimend breekt door steile klippen,


Ginds en her de breede vloed,
Langs den palm, die in hem spieglend,
Tiert in heldren zonnegloed.

[64]

Vruchtloos spilt op ’t rotsgevaarte


Eeuwenlang de golf haar kracht:
In de uiteengespatte waat’ren
Speelt des lichtstraals kleurenpracht.

Onder, waar de golven woeden,


Ligt een volk in eeuwge rust;
Uit zijn bakermat verdreven,
Zoekt het toevlugt aan deez’ kust 26.

Vrank en vrij, gelijk hij leefde


Zonk de Alurenstam in ’t niet;
’t Laatste spoor zijns droeven aanzijns
Dekt nu ’t groenend oeverriet.

’t Laatste?—Neen, van ’t berggevaarte


Schalt de Papegaai zijn kreet;
Aan de rots zijn snavel wettend,
Klaagt hij der Arturen leed.

Ook de knapen, die hem leerden


Klanken van hun moedertaal,
En de vrouwen, die hem voedden,
’t Nest hem bouwden—allemaal

Liggen dood en wreed verslagen,


Langs den oever uitgestrekt;
En de noodkreet van den vogel
Heeft geen hunner nog gewekt.

Eenzaam roept hij, in den vreemde,


Dan zijn woord wordt niet verstaan;
Hij hoort slechts de golven 27 ruischen
Zijner trekt zich niemand aan.

En de wilde rept de riemen,


Wendt zijn vaartuig, schuwt de baai,
Ziet hij huivrend, angstig bevend
Den Aturen-Papegaai.

Hetzij dat deze overlevering op waarheid berust, of uit het dichterlijke


brein der Indianen is voortgesproten, zooveel is zeker, dat deze
papegaai ons op treffende wijze het sterven van de geslachten der
menschen [65]symboliseert. Dat zulks ook het lot is van een der meest
sympathieke volken der aarde—de Indianen—zal wel in de allereerste
plaats door hen betreurd worden, die de herinnering hebben behouden
aan een verblijf in hun midden, dat hun de hoogst denkbare
levenswijsheid heeft vermogen te schenken.

Mogen ook zij, die dit voorrecht niet gekend hebben, zich bij dit oordeel
hartgrondig aansluiten, wanneer hun geest zich in dezen bundel
gelaafd zal hebben aan het vele schoone, dat de Indianen-ziel siert, en
waarvan hunne mondelinge overleveringen zoo herhaaldelijk
getuigenis afleggen; en mogen de voorbeelden, die ik uit de rijke
litteratuur over den Indiaan voor deze Mythen- en Legenden-serie heb
gekozen, ook den lezers iets van de groote bekoring hebben laten
gevoelen, die niet alleen van het leven en de moraal van den Indiaan,
maar ook van de machtige natuur der maagdelijke wouden, te midden
waarvan de Zuid-Amerikaansche stammen nog leven, in zoo hooge
mate uitgaat! [66]
[Inhoud]

Indianen-Vertellingen.

No. 1. De sage van Haboeri (W.)

Heel, heel lang geleden leefden er in een Warrau-kamp twee zusters,


die veel van elkander hielden, doch die geen van beiden een man
hadden. De zorg voor haar dagelijksch voedsel drukte haar zwaar. Eens
op een dag gingen zij er op uit, om een Ita-pálm* te vellen, waaruit zij
meel wilden bereiden. Het was al laat geworden, toen zij den boom
eindelijk tegen den grond hadden gekregen, en togen vermoeid naar
haar hut terug.

Den volgenden dag, toen zij naar haar werk terug keerden, vonden zij
het meel reeds gereed liggen. Hoe dat zoo kwam, konden zij maar niet
ontdekken. Den volgenden dag—precies hetzelfde; het meel lag voor
haar gereed. Daar ze er het fijne van wilden weten, besloten zij de
nacht bij den boom door te brengen en goed op te letten. Toen het
middernacht was, konden zij hare oogen niet gelooven, toen zij zagen,
dat een blad van een nabijstaanden Palissadepalm* zich voorover
boog, totdat het de snede, die zij in den op den grond liggenden Ita-
stam hadden gemaakt, raakte. Nauwelijks hadden de vrouwen de
aanraking gezien, of zij stoven naar voren, grepen het zoo geheimzinnig
doende blad beet, en smeekten het vurig, zich in een man te willen
veranderen. Eerst weigerde het; maar toen ze aandrongen, ziet, toen
gebeurde het wonder.

De man, die zij vóór zich zagen, zei, Mayara-Koto te heeten. De oudste
zuster, die hij tot zich nam, was nu overgelukkig, want eenigen tijd
daarna schonk zij hem een prachtigen jongen. Haboeri was zijn naam.
De beide vrouwen, die gewoon waren, in de nabijheid van twee
swampen* te jagen, vonden in de eene, die haar eigendom was, steeds
rijkelijk visch. De andere behoorde [67]echter aan Tijger* en daarom
waarschuwden zij Mayara-Koto, niet in Tijger’s swamp te gaan
visschen. De man luisterde echter niet. „In onze swamp is te weinig
visch”, zei hij, „in die van Tijger is er overvloed. Ik ga zien, wat ik vang.”
Maar nauwelijks was hij begonnen, of Tijger kwam voorbij, greep hem
en velde hem met één slag neêr.

En wat deed nu Tijger? Hij vermomde zich in de gedaante van Mayara-


Koto, en zoo ging hij op weg. Het was al vrij laat en donker geworden,
toen hij de hut der beide vrouwen had bereikt. Hij bracht niet alleen
Mayara-Koto’s waiyarri* mede, maar ook de visch, die hij van Tijger
gestolen had. Zooals gewoonte is, zette hij, alvorens de hut binnen te
gaan, de korf buiten de hut neêr en na goeden avond! gezegd te
hebben, zei hij, dat hij wat visch had meêgebracht. De vrouwen waren
hoogst verbaasd, de ruwe stem van Mayara-Koto te hooren. „Ik ben erg
vermoeid, en zoek dadelijk mijn hangmat op, maar geef me mijn lieven
Haboeri, want ik wil hem koesteren.”

Hoewel de stem den vrouwen niet beviel, voldeden zij aan zijn
verlangen. „Breng de visch binnen, en maak ze klaar. Ik ga nu slapen
en stoor mij niet.” Toen de vrouwen met de visch gereed waren, en
reeds begonnen te eten, was de man in zóó diepen slaap gevallen en
zóó hard aan het snorken gegaan, dat men het wel aan den anderen
rivieroever had kunnen hooren. Verbaasd zagen de beide vrouwen
elkander aan, toen zij tusschen het snorken door vader’s naam,
Mayara-Koto, hoorden roepen. „Onze man heeft vroeger nooit zoo
gesnorkt; nooit hebben wij hem zijn eigen naam hooren noemen”, zei
de oudste. Zij begonnen steeds angstiger te worden en konden
nauwelijks verder eten, want het was toch niet mogelijk, dat het haar
man was, die in de hangmat lag.
„Wat moeten we met Haboeri doen; hoe moeten we hem uit de armen
van den vreemden man bevrijden”, [68]zeiden ze tegelijk. „Ik heb een
idee”, riep de jongste, „we zullen een bundel vezels en bastrepen bij
elkander binden, en dezen onder Haboeri schuiven; daarna zullen we
hem voorzichtig wegnemen”. Zoo gezegd, zoo gedaan. Met Haboeri
onder den arm namen de beide vrouwen haastig de vlucht, na gezorgd
te hebben het noodige mede te nemen, om vuur te kunnen maken.

Toen ze een eind op weg waren, hoorden zij Wau-oeta zingen—Wau-


oeta was in die dagen een piaivrouw—die met haar maráka* bezig was.
Zij versnelden haar pas, want zij wisten, dat zij in Wau-oeta’s hut veilig
zouden zijn.

Inmiddels was Tijger wakker geworden, en toen hij zag, dat in plaats
van Haboeri, een bundel vezels en bast in zijn armen lag, en bemerkte,
dat de beide vrouwen gevlogen waren, werd hij zóó woedend, dat hij uit
de hangmat sprong, en na weder de tijgergedaante te hebben
aangenomen, de achtervolging begon. Maar de vluchtelingen hadden
de hut van de piai-vrouw reeds bereikt. „Wau-oeta, doe de deur open 28,
riepen zij. „Wie is daar”, antwoordde Wau-oeta. „Wij zijn het, de twee
zusters”, riepen de achtervolgden. Maar Wau-oeta deed niet open. Toen
kneep de moeder in Haboeri’s oor, zoodat het kind hard begon te
schreeuwen. „Wat is dat voor een kind, een jongen of een meisje”,
vroeg toen Wau-oeta. „Het is mijn Haboeri, mijn jongen”, antwoordde
zijn moeder, en onmiddellijk deed Wau-oeta nu open, verheugd
uitroepende: „Kom binnen, kom binnen.”

Nauwelijks waren nu de drie vluchtelingen in veiligheid, of Tijger kwam


aanloopen, die buiten brulde: „Waar zijn de beide vrouwen, waar is de
jongen?” Maar Wau-oeta opende niet en riep Tijger toe, dat ze geen
van drieën [69]had gezien. „Ik ruik, dat ze er zijn, dus zal ik buiten
wachten”, antwoordde Tijger. Dit verontrustte Wau-oeta zoo, dat zij met
bevende stem zei: „Steek je hoofd maar binnen, en wanneer je ze ziet,
mag je ze alle drie opeten”.
Doch de deur was van binnen geheel bedekt met dorens* zoodat
onnoozele Tijger, toen hij zijn hoofd naar binnen stak, bleef haken en
door Wau-oeta gedood werd.

De beide zusters begonnen hevig te jammeren, en om haar man te


roepen, en toen zij maar niet wilde ophouden, verzocht Wau-oeta haar
naar den kostgrond* te gaan, om wat Cassave te gaan halen. Ze zou
dan een flinken drank* kunnen bereiden. Toen de beide vrouwen wilde
vertrekken en de kleine Haboeri wilde medenemen, belette Wau-oeta
dit, zeggende, dat zij evengoed op het kind kon passen. De zusters
stemden er eindelijk in toe.

Middelerwijl had Wau-oeta—in den ouden tijd kenden de piaimannen en


piaivrouwen alles—het kind zóó hard doen groeien, dat het zelfs op de
yarri-yarri* kon blazen en pijl en boog kon hanteeren.

Toen moeder en tante met de ingezamelde cassave-wortels terug


kwamen, en het fluitspel hoorden, zeiden zij tot elkaar: „Er was toch
geen man in de hut, toen we deze verlieten. Hoe kan dat? Er moet hier
een man zijn”. Min of meer verlegen traden ze binnen, en toen ze daar
een bijna volwassen jongeling zagen, die bezig was de yarri-yarri te
bespelen, namen ze de korven van den rug en vroegen Wau-oeta naar
Haboeri: „Zoodra je vertrokken waart, is hij de hut uitgeloopen. Ik was in
de meening, dat hij nog in je gezelschap was”, antwoordde Wau-oeta,
die erin geslaagd was, Haboeri zóó groot te krijgen, dat hij nu spoedig
haar geliefde zou kunnen zijn. „Laten we”, zoo stelde ze de vrouwen
voor, „hem in het bosch gaan zoeken”.

Toen zij een klein eind op weg waren, zei Wau-oeta nog even terug te
moeten; ze zou dadelijk terugkomen, [70]en van dat oogenblik maakte
Wau-oeta gebruik, om Haboeri te vertellen, dat zij zijn moeder was, en
lichtte hem in, hoe hij zich tegenover haar moest gedragen.

Haboeri was in dien tijd een kranig schutter geworden; geen vogel
ontsnapte aan zijn pijlen. Wau-oeta daarmeê zeer ingenomen, gelastte
Haboeri, in het vervolg alle vogels, die hij zou dooden, aan haar te
geven, en de kleinere, na ze vooraf ongenietbaar te hebben gemaakt,
aan de beide zusters. Zij hoopte, dat deze eindelijk er genoeg van
zouden krijgen en ten slotte de hut zouden verlaten. Maar zij waren er
niet toe te bewegen en gaven hare pogingen, om Haboeri te vinden,
niet op.

Dagen achtereen ging dit zoo zijn gang. Wau-oeta kreeg de groote
vogels, de kleinere bleven voor moeder en tante, tot eens op een dag
een pijl van Haboeri niet raakte en aan een over een kreek hangenden
tak bleef hangen, op een plek, waar zijn ooms, de waterhonden*,
gewoon waren, voedsel te komen zoeken.

Het was een mooie open plek in het bosch en Haboeri maakte het zich
gemakkelijk, na het achtergelaten vuil der dieren met bladeren te
hebben bedekt. Hij klom in den boom, om zijn pijl vrij te maken, toen op
het zelfde oogenblik de otters aan kwamen zwemmen. Nauwelijks
aangekomen, snoven ze de lucht op en riepen tegelijk: „Wat ruik ik
daar? Het is stellig onze neef Haboeri, die hier dichtbij moet zijn”.
Overal keken ze rond en eindelijk ontdekten ze hem op den tak. „Kom
beneden”, riepen zij, „en zet je op deze zandbank neêr”.

Haboeri voldeed aan het verzoek, en de otters legden hem toen uit, dat
hij een slecht leven leidde, want dat de oude vrouw zijn moeder niet
was, doch de beide jongere vrouwen zijn moeder en tante waren, en
het dus zeer slecht van hem was, de vogels zóó te verdeelen; dat hij in
het vervolg juist de kleinsten aan de oude vrouw moest [71]geven. Zij
beduidde hem, dat hij aan zijn ware moeder moest vertellen, dat hij
tegenover haar verkeerd gehandeld had, dat hij onwetend was en er
spijt van had.

Toen Haboeri dien dag thuis kwam, volgde hij de bevelen der otters op,
en ontving de ware moeder de groote vogels. Zij van haar kant voelde
zich dien dag vreemd te moede; het was haar moeielijk, den jongen
man dadelijk als haar zoon aan te spreken. Maar toen deze haar
uitlegde, dat Wau-oeta hem in zóó korten tijd tot een man had gemaakt,
geloofde zij hem, en voelde zich geheel opgebeurd. De oude Wau-oeta,
dit alles hoorende, wond zich zoodanig op, dat zij, Haboeri bij den nek
pakkend, hem in het gezicht blies. Zóó was zij van streek, dat zij den
geheelen dag niet kon eten. Dag en nacht plaagde zij Haboeri en ieder
oogenblik riep zij, dat hij zijn zinnen verloren had.

Haboeri, ten einde raad, vatte het plan op, de hut te verlaten, en haalde
zijn moeder over, zoo spoedig mogelijk met hem en zijn tante te
vluchten. Te dien einde maakte hij een kleine korjaal van bijenwas
gereed, en toen hij daarmede gereed was, liet hij hem aan den
waterkant. Toen hij echter den anderen dag terugkwam, had een zwarte
eend het vaartuig weggenomen. Hij maakte toen een nieuwe korjaal,
ditmaal van klei, maar deze werd door een andere eend gestolen.
Haboeri kapte toen een groot terrein open en hij deed het zóó gauw, dat
de vrouwen hem met het planten van cassave haast niet bij konden
houden. Zoo hadden zij volop cassave voor de voorgenomen reis.

Dikwijls, als de vrouwen plantten, sloop Haboeri weg en maakte een


korjaal, telkens van een ander hout en een anderen vorm; maar
geregeld kwam er een andere eendsoort om hem weg te nemen, tot hij
er eindelijk een gemaakt had van het hout van den Kankantrie* en deze
werd niet gestolen. [72]

Haboeri was het dus, die het eerst een boot maakte en aan de eenden
leerde, aan de oppervlakte van het water te zwemmen, omdat het met
zijn booten was, dat zij het klaar speelden. Inderdaad, wij, Warraus
zeggen, dat iedere eendsoort een bepaalde boot heeft.

Maar wat nog vreemder was, de laatst gemaakte boot, die niet gestolen
was, was den volgenden dag veel grooter geworden. Haboeri bracht de
heuchelijke tijding dadelijk aan zijn moeder en tante, en verzocht haar,
alle provisie, die ze van het land konden halen, voor de lange reis in de
boot te brengen. Hij begaf zich zelf naar het veld, om er de cassave-
stekken te brengen, die de oude Wau-oeta in de gereedgemaakte gaten
moest steken, en zoo gingen zij nog een tijd met hard werken voort.
Toen alles voor de reis gereed was, begaf Haboeri zich naar de hut,
nam pijl en boog, en steenen bijl* en keerde met zijn wapens en
gereedschap naar de waterkant terug. Maar te voren drukte hij de
posten of hutpalen op het hart—want in vroeger dagen konden deze
spreken 29, zoodat bij afwezigheid van den eigenaar, een vreemde
bezoeker kon te weten komen, waar hij was—vooral niets te vertellen.
Maar er was een papegaai in de hut, en Haboeri vergat ook hem in te
lichten en het zwijgen op te leggen.

Zoo kwam het, dat, toen de oude Wau-oeta, zich eenzaam en verlaten
voelende, en bemerkende dat Haboeri verdwenen was, aan de posten
vroeg, waar hij gebleven was. Deze antwoordden echter niet, maar de
papegaai kon het niet helpen, dat hij begon te spreken en haar inlichtte.
Onmiddellijk ijlde Wau-oeta naar de landingsplaats, en zij kwam nog
juist bij tijds, toen Haboeri op het punt was, in de korjaal te stappen en
met zijn moeder en tante weg te parelen. Zij greep de boot en
jammerde: „Mijn zoon, mijn zoon, je moogt me niet verlaten. Ik [73]ben je
moeder” en niettegenstaande Haboeri met zijn parel hare vingers bijna
tegen het dolboord stuk sloeg, wilde zij niet loslaten. Arme Haboeri zag
zich dus genoodzaakt aan land te gaan, waar hij de oude Wau-oeta bij
een hollen boom bracht, waarin bijen genesteld waren. Haboeri velde
den stam en drong er op aan, dat zij er in zou kruipen, om de honig,
waarvan zij zooveel hield, te verzamelen. En Wau-oeta, al maar
schreiende bij de gedachte, Haboeri te zullen verliezen, kroop naar
binnen, waarna Haboeri onmiddellijk de opening sloot.
… en niettegenstaande Haboeri met zijn parel hare vingers
bijna tegen het dolboord stuk sloeg …—Zie blz. 73.

En daar is de Wau-oeta-kikvorsch* nog tot op den huidigen dag te


vinden, die men alleen in holle boomen kan hooren. Wanneer men het
dier goed bekijkt, kan men zien, hoe gezwollen haar vingers zijn door
de slagen, die haar door den parel waren toegebracht, toen zij de boot
met alle macht tegenhield. En als men luistert, kan men haar nog altijd
hooren jammeren om het verlies van haar beminde, wanneer zij roept:
Wang! Wang! Wang!

Deze geschiedenis van den mythischen Haboeri, die een nationale held
der Warraus is, geeft onder de vele voorstellingen omtrent het ontstaan
van menschen, en het verband tusschen menschen en dieren, ook een
verklaring voor de bekende kundigheid der Warraus, om de
voortreffelijkste booten te maken.

Later is bij de vertelling dezer mythe nog toegevoegd, dat Haboeri


wegvoer, nieuw land ontdekte, waar blanken woonden, wien hij
onderwees in alle kundigheden der Warraus.

No. 2. De oorsprong der eerste menschen (C.)

De bewoners van den hemel gluurden eens door een opening, die zij,
zooals hen geleerd was, niet mochten naderen, naar beneden, en
ontdekten toen een geheel andere wereld. Zij sneden toen lange
[74]bastrepen en lieten zich er mede naar beneden zakken.

Toen zij nu een tijd lang op de aarde hadden rondgedoold, begonnen zij
angstig te worden en besloten zij weder naar boven te klimmen. Nadat
zij nu weder de opening, waaruit zij waren neêrgedaald, hadden bereikt,
bleef een vrouw, die buitengewoon breed en zwaar was, in het gat
steken en gedurende het gevecht en het gedrang, dat er ontstond, om
binnen te komen, brak de bastreep af en een aantal Caraïben vielen
naar beneden en waren nu genoodzaakt op de aarde te blijven.

Toen zij echter geen eten konden vinden, dat naar hun smaak was,
zagen zij zich genoodzaakt, aarde te eten, waarvan zij koeken bakten.
Zij begonnen echter hoe langer hoe magerder te worden, en toen zij
bemerkten, dat de Acouri* er zoo welgedaan uitzag, zetten zij een
Specht* op den uitkijk, om te weten te komen, op welke wijze de Acouri
zich voedsel verschafte. Maar de specht verried zichzelf door zijn getik
tegen den stam, toen het kleine dier naar buiten kwam. Zij droegen nu
den Alligator* op, om het te bespieden; deze keerde terug, maar
vertelde een leugen. Na hem daarvoor gestraft te hebben, door zijn
tong uit te snijden 30, zonden zij er een rat op uit; doch deze keerde niet
terug en het volk moest hongerlijden. [75]

De menschen trokken toen naar elders, alleen een kind achterlatend.


Toen zij nu na langen tijd, waarin zij zich met bessen hadden moeten
voeden, op de plaats terugkeerden, troffen zij het kind niet alleen nog
levend, maar zeer welgedaan, te midden van een aantal maïskolven
aan. De Acouri, die het kind zoo lang met maïskorrels had gevoed, was
na een zijner bezoeken door het kind gevolgd en dit had toen het
maïsveld ontdekt, waaruit het zoo lang eten had gekregen. Het volk was
nu gered en nam in aantal toe.

No. 3. De oorsprong van het menschdom (W.)

Eens op een dag was Okonoróté op jacht en wilde een zeldzamen


vogel zien te bemachtigen—in die tijden leefden de Warraus boven in
de lucht en kenden zij geen andere dieren dan vogels—en
verscheidene dagen gingen voorbij, voor hij eindelijk met zijn pijl het
verlangde dier doorboord had. Maar toen hij naar de plaats snelde,
waar de vogel was neêrgevallen, was deze verdwenen en zag hij
beneden zich een groot gat, waardoor hij allerlei dieren, als herten,
wilde zwijnen op het groen onder zich zag loopen. Met behulp van een
katoenen band daalde hij nu op aarde neder en hij zag daar jagoears,
slangen en andere wilde dieren hun prooi verslinden.

Verlangend om ook eens van die dieren, die hij niet kende, te proeven,
was hij zoo gelukkig een jong hert te schieten, waarvan hij het vleesch
braadde; en zóó lekker smaakte hem dit, dat hij besloot er mede weder
aan den katoenen band naar boven te klimmen. Alle Warraus waren nu
natuurlijk verlangend, om Okonoróté naar beneden te vergezellen, toen
hij zijn tocht naar de aarde wilde herhalen.

Toen nu de laatsten door het gat wilden zien te komen, gebeurde het,
dat een buitengewoon dikke vrouw in het [76]gat niet heen weêr kon
komen, en daar moest blijven, zoodat de Warraus genoodzaakt waren,
altijd op de aarde te blijven.

De bewuste vrouw heette Okona-koera en de Warraus zien haar nog


altijd als de morgenster.

No. 4. De oorsprong der Caraïben. (C.)

De water-camoedi* beminde een Indiaansch meisje. Des nachts nam


het monster menschengedaante aan. Overdag werd het weêr slang.
Het paar was gewoon, elkander geregeld aan den rivieroever te
ontmoeten, maar de ouders van het meisje waren onkundig van dit
samenzijn.

Dit had zoo een poos geduurd, toen een jonge camoedi geboren werd.
Het jong vertoonde zich nu en dan op een zandbank, zwom in het water
heen en weêr en keerde daarna weder naar het nest terug.

Toen het meisje zoo lang wegbleef, zei de vader tot zijn beide zoons:
„Wat is er toch met jelui zuster. Waarom blijft zij zoo lang in het bad?”
Daar de zoons er ook niets van begrepen, werd overeengekomen, dat
zij naar den rivieroever zouden gaan om haar te bespieden. En wat
zagen zij? Hun zuster in teedere omarming met een waterboa en in de
nabijheid van het verliefde paar een jonge camoedi. Zij bleven kijken en
zagen, dat de oude camoedi aan zijn jong eten bracht.

Toen de zoons, weêr in de hut teruggekeerd, aan den ouden man


vertelden wat ze hadden gezien, schrok hij hevig en beval de camoedis
onmiddellijk te dooden.

Bij de eerste goede gelegenheid deden ze wat hen bevolen was. Zij
doodden den oude en sleepten het jong naar het achterliggende bosch,
waar zij het in een menigte stukjes sneden.

Eenige maanden later, toen zij in den omtrek aan het jagen waren,
hoorden de broêrs een groot lawaai en het [77]geluid van een menigte
stemmen, dat van de plek scheen te komen, waar zij de jonge camoedi
gedood hadden; en toen zij zich in de richting begaven, van waar de
stemmen kwamen, zagen zij juist op de plek, waar zij de jonge slang in
stukken hadden gesneden, vier hutten, elk bewoond door Indianen, die
uit de stukken van de jonge camoedi te voorschijn gekomen waren.

In de voorste hut zei de oudste der bewoners tot de broêrs, dat hij
verheugd was, hen als hun ooms te kunnen verwelkomen; maar in de
andere drie wilden de Indianen hen dooden, omdat zij het kind van hun
zuster, waaruit zij geboren waren, gedood hadden. Maar de Indiaan uit
de voorste hut zei: „neen, doe dat niet, want deze twee bezoekers zijn
immers jelui ooms, en jelui moet hen daarom genegen zijn.”

En zoo gebeurde het, dat de beide broêrs onverlet bij hun ouden vader
kwamen, wien zij vertelden, dat uit de deelen van de stuk gesneden
jonge camoedi menschen waren gegroeid.

De vader was nu zeer verheugd en kon nauwelijks wachten, zijn


kleinkinderen te zien. Met zijn zoons begaf hij zich den anderen morgen
vroeg op weg en toen hij zijn talrijke nakomelingschap zag, was hij zóó
verrukt, dat hij voorstelde, de gebeurtenis met paiwarri* te vieren.

En zoo zijn de Caraïben uit een water-boa voortgekomen.

No. 5. Hoe de Caraïben gekweekte planten leerden kennen. (C.)

Er was een tijd, dat de Indianen geen cassave hadden en dat zij allen
honger leden. Ook de dieren hadden weinig te eten en leden honger.
Alleen Maipoeri* ging geregeld iederen morgen er op uit en ’s avonds
kwam hij glimmend van gezondheid en vet van zijn tochten terug. De
andere dieren die de overblijfselen van zijn maal—[78]bananenschillen,
suikerrietresten, enz.—zagen liggen, zeiden tegen elkander: „Maipoeri
moet zeker een goede plaats gevonden hebben, waar hij eten vindt.
Laten we hem volgen”. Alzoo zonden zij er den volgenden morgen de
Boschrat* op uit, die hem op de hielen zou volgen. Zoo hoorden zij, op
welke wijze hij er zoo lekker doorvoed uitzag. Want toen de boschrat
deed, wat hem was opgedragen, en Maipoeri ver in het bosch volgde,
zag zij hem eindelijk onder een enormen boom halt houden en de
vruchten oprapen, die naar beneden waren gevallen.

Deze boom was de Allepántepo, en wonderlijk, al wat maar kon


verlangd worden, groeide op zijn takken—maïs, bananen, 31 cassave,
jams*, ananassen* enz.

Zoodra nu Maipoeri zijn maag gevuld had, klom de rat in den boom,
verzadigde zij zich aan maïs en toen zij niet meer kon, daalde zij weêr
naar beneden, een korrel meebrengend om haar lotgenooten te laten
zien, wat zij gevonden had.

De Indianen volgden den anderen morgen de rat op weg naar den


boom en toen zij ter plaatse waren aangekomen, zagen ze onder den
boom een menigte bananen, jams, tajerknollen* en ananassen liggen,
die de boom had laten vallen. Nadat ze zich aan alles te goed hadden
gedaan en er niets meer was blijven liggen, probeerden zij in den boom
te klimmen, om nog meer te halen; maar de stam was te glad en te dik,
zoodat zij moesten besluiten, den boom te vellen.

Zij maakten een stellage om den stam en begonnen met hun steenen
bijlen* den boom te bewerken. Tien dagen bleven ze hakken, maar hij
wilde maar niet vallen—zoo’n kolos was Allepántepo. Nog eens tien
dagen gingen ze er meê voort, en nog hadden ze hem niet naar
beneden. [79]

De Indianen begonnen er dorst van te krijgen, en daarom deelden zij


aan alle dieren een kalebas uit, om water voor hen te gaan halen;
alleen aan Maipoeri gaven ze er een, die als een zeef doorboord was.
Toen de dieren de rivier bereikt hadden, begonnen zij uit de kalebas te
drinken, maar bij Maipoeri wilde het niet lukken, want zóó was zijn
kalebas vol water, of het liep er even hard weêr uit; dit was reeds een
deel van zijn straf, zoo begeerig te zijn geweest, om het geheim van
den milden boom alleen voor zich te willen houden.

Eindelijk, na nog eens tien dagen gewerkt te hebben, viel de boom


neêr. De Indianen namen toen als hun aandeel al de cassave, het
suikerriet, de jams, de tajers, de bananen, pompoenen, de
watermeloenen er af, terwijl Acouri, Oerana* en andere dieren op de
takken der boomen klommen, om, wat hun tot voedsel kon strekken, er
af te halen.

Maipoeri keerde na eenigen tijd van den rivieroever terug en toen hij
zag, dat voor hem alleen de pruimen* waren overgebleven, was hij zeer
vertoornd. Nog altijd moet de Tapir voor zijn inhaligheid boeten; want hij
moet zich nog steeds daarmede tevreden stellen.

Wat de Indianen op den wonderboom hadden ingezameld, namen zij


naar hun dorp mede, en legden er hun kostgronden meê aan. De
Bunia-vogel* was het, die hen alles omtrent de cultuurplanten uitlegde,
de kweekwijze en de toebereiding, vooral op het hart drukkend, de
bittere cassave* vóór het gebruik goed te koken.

No. 6. De dochter van den geestenbezweerder.

De dochter van een piaiman werd tot over de ooren verliefd op een
dapperen, jongen jager; maar deze nam weinig notitie van het meisje.
Zij wendde zich nu tot haar vader, en klaagde hem haar nood, er bij
voegende, dat [80]de jonge man toch een vrouw diende te hebben, die
hem bij zijn thuiskomst kon verzorgen. Het meisje smeekte nu haar
vader, om van haar een van ’s mans honden te maken, zoodat zij altijd
bij hem zou kunnen zijn.

„Neem dit vel”, zei de vader, „en hang het over je schouders. Wees
bevrijd van je dolzinnigheid, en—kom weêr bij je vader terug.” Het
meisje veranderde nu in een hond. Telkens, wanneer nu de jonge man
met vier honden op jacht was, rende er altijd een in den namiddag weg,
die niet langer aan den strijd wilde deelnemen—en wat vreemder was,
als de jager in zijn hut terugkeerde, vond hij het vuur branden, zijn
cassavebrood gebakken, en alles netjes en helder.

De man dacht, dat hij dit alles aan een van zijn buren te danken had,
wien hij daarom een bezoek ging brengen, om voor de zorg te
bedanken. Maar niemand wist iets van het geval. „Het mag dan
misschien een of andere Geest geweest zijn, die medelijden met mijn
eenzaamheid heeft gehad,” gaf hij ten antwoord. Toen hij deze woorden
sprak, zag een zijner honden hem zoo vreemd aan, alsof hij zeggen
wilde: „ik weet er ook niets van.” De man begon nu over het geval te
piekeren.

Den volgenden dag, toen hij weêr op jacht was, telde hij zijn honden en
bemerkte hij, dat er maar drie waren, „Ik ga toch eens zien, wat jelui
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like