How Javascript Works Master The Basics Of Javascript And Modern Web App Development 1st Edition Jonathon Simpson pdf download
How Javascript Works Master The Basics Of Javascript And Modern Web App Development 1st Edition Jonathon Simpson pdf download
https://ebookbell.com/product/how-javascript-works-master-the-
basics-of-javascript-and-modern-web-app-development-1st-edition-
jonathon-simpson-54604020
How Javascript Works Master The Basics Of Javascript And Modern Web
App Development 1st Edition Jonathon Simpson
https://ebookbell.com/product/how-javascript-works-master-the-basics-
of-javascript-and-modern-web-app-development-1st-edition-jonathon-
simpson-54544624
How Javascript Works Master The Basics Of Javascript And Modern Web
App Development Jonathon Simpson
https://ebookbell.com/product/how-javascript-works-master-the-basics-
of-javascript-and-modern-web-app-development-jonathon-simpson-55667652
https://ebookbell.com/product/how-javascript-works-douglas-
crockford-21976016
Learn D3js Simple Way Learn How To Work With D3 Javascript Libraries
In Stepbystep And Most Simple Manner With Lots Of Handson Examples
Nuno Correia Ajay Nayak
https://ebookbell.com/product/learn-d3js-simple-way-learn-how-to-work-
with-d3-javascript-libraries-in-stepbystep-and-most-simple-manner-
with-lots-of-handson-examples-nuno-correia-ajay-nayak-55922952
Reliable Javascript How To Code Safely In The Worlds Most Dangerous
Language 1st Edition Lawrence Spencer
https://ebookbell.com/product/reliable-javascript-how-to-code-safely-
in-the-worlds-most-dangerous-language-1st-edition-lawrence-
spencer-5131426
https://ebookbell.com/product/functional-programming-in-javascript-
how-to-improve-your-javascript-programs-using-functional-techniques-
first-edition-luis-atencio-55892992
https://ebookbell.com/product/asynchronous-programming-patterns-in-
javascript-how-to-use-asyncawait-and-promises-to-solve-programming-
problems-tams-sallai-33377304
https://ebookbell.com/product/learn-how-professionals-write-
javascript-in-the-industry-mendoza-232147582
https://ebookbell.com/product/instant-interactive-map-designs-with-
leaflet-javascript-library-howto-jonathan-derrough-43741254
Jonathon Simpson
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
1. Introduction to JavaScript
Jonathon Simpson1
(1) Belfast, Antrim, UK
JavaScript Fundamentals
JavaScript is based on a language standard called ECMAScript. How
JavaScript should exactly work is documented in a specific standard
called ECMA-262. Since ECMAScript does not provide any tools to
compile JavaScript, every implementation of JavaScript creates its own
version of JavaScript. That includes your browser and back-end
compilers like Node.js.
For the most part, these implementations follow ECMA-262, but
since each implementation is done by different teams, there can be
some minor discrepancies or different feature sets depending on the
browser or implementation.
In this chapter, we will be covering how you can set yourself up to
start using JavaScript, including how to set up JavaScript projects when
using Node.js. In future chapters, we will explore how to write
JavaScript code.
You’ll see that no types are defined here. For example, we did not
have to mention that "Some String" was a String. JavaScript
determines types based on context – so it will take x to be a String
simply because we put its value in quotation marks. Similarly, it will
dynamically interpret y as being of type Number since it lacks
quotation marks and z as being of type Boolean since it has no
quotation marks and uses the keyword false.
This makes JavaScript quite easy to pick up, but quite hard to
master. The lack of strong typing can mean that you unknowingly create
bugs in your software since JavaScript will not always throw errors if
unexpected types show up, and even worse, JavaScript may dynamically
interpret types incorrectly in some cases.
For more complex applications with lots of test cases, developers
often reach for TypeScript instead of JavaScript for this reason.
TypeScript is JavaScript, but extended. It’s strongly typed, meaning
types must be mentioned in your code.
Writing JavaScript
JavaScript on the front end is found inside HTML on web pages. As such,
familiarity with HTML is quite important when we work with
JavaScript. To create your first file containing JavaScript, you can start
by making a .html file. We usually call the home page of a website
index.html when building websites, so for this example, I created a
new HTML file called index.html.
.html files can be opened by any web browser, such as Google
Chrome. You can edit your HTML file by opening it up in a text or code
editor (Notepad included), and puting in this standard “boilerplate”
HTML:
<!DOCTYPE html>
<html>
<head>
<title>My First JavaScript</title>
</head>
<body>
<p>Hello World</p>
<script type=”text/javascript”>
// This is JavaScript!
</script>
</body>
</html>
Note You can use any text editor (like Notepad) to create HTML
and even JavaScript. While that works fine, it’s better to use a
professional code editor instead. One of the most popular code
editors used in the software development community is VS Code.
You can download it via https://code.visualstudio.com/.
This will color code your JavaScript and give you a lot of other useful
features.
<script type="text/javascript">
// This is JavaScript!
</script>
Since JavaScript applications can get quite long, you may see this
<script> tag substituted out for a file instead. This can be useful
since it lets us separate our HTML and JavaScript into different files.
For example, if we had a separate JavaScript file called
myScript.js stored in the same folder as index.html file, we
could load that into our HTML document by using the src attribute on
the script tag:
<script src="myScript.js"></script>
You may also see JavaScript embedded into HTML via the attributes
of HTML tags. For example, JavaScript can be put inside a button to
cause something to happen when a user clicks that button:
Then you can execute this file by using the node command in
terminal:
node index.js
Figure 1-3 Running a JavaScript script from the command line is as simple as using the “node”
command followed by the directory link to the file you want to run
Note If you saved your index.js file in another directory, you will
need to provide the full directory link. To navigate directories, use
the cd command. For example, if your index.js file was in
“/Users/JohnDoe/Documents/”, you would run cd
/Users/JohnDoe/Documents/ and only after that, run node
index.js.
Node.js applications like this are frequently used to create APIs,
which we will cover in much more detail later in the book.
Creating Node.js JavaScript Projects
In the above example, we executed a single file using Node.js It is more
common, though, to create a Node.js project when you start something
new in Node.js. This is also done via terminal or the cmd. The first step
is to make a new folder and navigate to it using the cd command.
In this example, I made a folder called “node-project” on my desktop
and navigated to it using the following command in Terminal:
cd ~/Desktop/node-project
After that’s done, you can use the npm init command, which is
installed along with Node.js, to initiate your project. You can see how
that looks in Figure 1-4.
Figure 1-4 When using the npm init command, you will be asked to enter some information
about your new project as shown earlier
All you have to do now is type in answers to each question and
press enter. For example, the first question asks what you want to call
your project – so type in the name of your project, and press enter.
Your folder will now contain a package.json file summarizing
the information you provided. Since you’ve initialized your Node.js
project, you’ll now be able to run other commands like npm install
now, which lets you install third party dependencies.
JavaScript Support
Traditional software is usually written by a developer and downloaded
onto a user’s computer or device. This is the case with things like video
games, apps on your phone, or big applications like Adobe Photoshop.
When writing code in JavaScript, things are very different. The
software the user installs is the browser, not your website! The browser
then loads your web page within it. Since everyone has their own
browser preference, and not everyone keeps their browsers up to date,
JavaScript that works in one browser can oftentimes not work in
another. For example, Firefox may support a new JavaScript feature, but
Chrome may not. The worst thing about this is you can’t really use a
new JavaScript feature on the front end until a majority of browsers
have implemented it.
If you are coming from other languages, then worrying about
browser support will be a foreign concept to you. In JavaScript, it is a
real thing. In recent times, since most browsers are “evergreen”
(meaning they auto-update), this has become less of a problem than it
used to be, but sometimes different browsers just disagree on what
should and shouldn’t be implemented. Promising new features may end
up implemented in just Chrome, just Safari, or just Firefox.
Throughout this book, we’ll only be looking at JavaScript with broad
browser support, meaning you don’t need to worry about if you can or
can’t use it. However, when you start exploring JavaScript in your own
time, and especially when looking at more advanced functionality, it’s
important to check if browsers support it. You can find good browser
support tables on websites like https://caniuse.com/ or
https://developer.mozilla.org/.
An example of a browser support table can be found in Figure 1-5,
for the GPU feature.
Figure 1-5 Not all browsers support every new JavaScript feature. In the preceding example,
only Chrome and Edge have support. Other browsers only have partial support or none at all.
That means if you tried to implement this on a website, only some users could use it!
Summary
In this chapter, we’ve looked at how to set up your workspace to begin
writing code with JavaScript. We’ve discussed what JavaScript is
typically used for and some of the pitfalls or differences between it and
other languages. Now that we’ve covered the basics let’s look at how to
write JavaScript code.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
J. Simpson, How JavaScript Works
https://doi.org/10.1007/978-1-4842-9738-4_2
Getting Started
As we go through this chapter, it will be good to have a work space
where you can write and test your JavaScript. For these purposes, I’ve
created a folder called “javascript-project” in my documents
folder. Within that, I have created two files – index.html and
index.js.
Since our focus will be writing JavaScript, your HTML file can be
relatively simple:
<!DOCTYPE html>
<html>
<head>
<title>My First JavaScript</title>
</head>
<body>
<p>Hello World</p>
<script src="index.js"></script>
</body>
</html>
Any JavaScript code you want to try out can be put in index.js.
For now, I’ve only put a simple console.log method:
console.log("Hello World!")
Figure 2-1 Right-clicking in the web browser and selecting “Inspect” in Google Chrome (or
other browsers) allows you to access the console log. If you do this with the index.html file we
defined before, you’ll see “Hello World!” written here. The console is a powerful tool used for
debugging. When we use the console.log method, it shows up here!
Semicolons
For readability, JavaScript is sometimes written with a semicolon at the
end of each line. For example:
console.log("Hello World!");
console.log("Goodbye World!");
However, this is not necessary, and it’s also just as common to see
the same code written without semicolons:
console.log("Hello World!")
console.log("Goodbye World!")
console.log(5 +
6)
For the code in this book, we will be omitting the semicolon unless
it is really needed.
Spacing
One of the most vigorously fought over code conventions is whether to
use tabs or spaces for indenting. While there is essentially no right or
wrong answer to this, it is important to be consistent. If you use tabs,
then always use tabs for indents and likewise for spaces.
Unlike Python, indents play no functional role in JavaScript, but they
do serve to make your code more readable when others look at it.
While it is certainly fine to use tabs, spaces are going to cause you less
of a headache. That’s because different ecosystems and operating
systems can be configured to handle tabs differently, whereas spaces
are consistently sized across all systems.
In this book, we will indent with four spaces. Here is an example of
how that will look:
let myVariable = 5
if(myVariable === 5) {
console.log("The variable is 5!")
}
Note If you use the tab key instead of spaces in VS Code to indent
your code, you can configure VS Code to automatically convert these
to spaces if you want it to. The configuration option is found by
opening any file and selecting the “Spaces/Tab Size” option in the
bottom right-hand corner.
JavaScript Variables
As we begin writing JavaScript, the first thing you’re going to need to
learn about are variables. Variables are a way to assign a fixed name to
a data value. There are three ways to create a variable in JavaScript,
using three different keywords:
var
let
const
All JavaScript variables are case-sensitive, so myVariable is
different from MYVARIABLE. In JavaScript nomenclature, we
usually say that we “declare” variables.
let myVariable = 5
console.log(myVariable)
Note It may seem like we are putting data into the variable, but a
better way to think about it is we are making data and then pointing
the keyword “myVariable” at the data we just made.
It’s not possible to assign a variable with let twice. If you think of your
variable as pointing to some data, it’s easy to see why – the same
variable can’t point to two different pieces of data. For example, the
following code will produce the error, which is shown in Figure 2-2.
let myVariable = 5
let myVariable = 10
console.log(myVariable)
Figure 2-2 Variables defined with let cannot be defined multiple times. If you try to, it will
produce an error like the preceding one
let myVariable = 5
myVariable = 10
console.log(myVariable)
It may seem like the data has changed (or “mutated”), but actually
we’ve just made new data somewhere and pointed our variable to that
instead. The data “5” still exists somewhere. It just has no variable
pointing to it anymore. When a piece of data is no longer referenced in
our code, JavaScript may remove it from memory using something
called “garbage collection.” This allows JavaScript to free up memory
when data is no longer used.
let myVariable = 5
{
let myVariable = 10
console.log(myVariable)
}
console.log(myVariable)
Figure 2-3 While using let, our console produces two different lines, 5 and 10. This is
because let is assigned to its current scope – so setting myVariable to 10 in a separate scope
does not affect the original variable. If we used var instead, both lines would say 10 since
scope is ignored
Setting Variables with var
Most variables are set with let, but you may also see the keyword var
being used to set variables sometimes. Using var is the original way to
set variables in JavaScript. It is valuable to know this exists, but it is
generally not recommended that you use it over let.
Setting a variable with var looks a lot like what we did with let.
For example, here is a variable called myVariable, with a value of 5:
var myVariable = 5
The reason why we use let rather than var is because var has a
few quirks that let does not. For example, you can define a variable
twice with var, and no errors will be thrown:
var myVariable = 5
var myVariable = 10
console.log(myVariable)
Variables defined with var are also not block-scoped, meaning your
code can produce some odd results when redefining variables in block
scopes with var.
You may be wondering, “Why does JavaScript have two ways of
defining variables when let is a more controlled version of var?” The
answer to that is pretty simple, and it’s because var used to be the only
way to define variables in JavaScript, and a lot of legacy code uses it.
Later on, JavaScript created a better way to define variables using let,
but var couldn’t be removed since it would break many older code
bases.
let myVariable = 5
myVariable = 10
console.log(myVariable)
const myConst = 5
console.log(myConst)
const myConst = 5
myConst = 10
console.log(myConst)
Using const to define variables is better when you’re able to use it.
To understand why, you can think about the example we
discussed earlier where we used let to reassign a variable from “5” to
“10”. We talked about how the value “5” still exists in memory unless it
gets garbage collected. Since const variables cannot be changed,
garbage collection never has to run. That means less cleanup is
required, resulting in more efficient memory utilisation.
Arrays can contain a lot of data, and we can push new data to an
array using a special method called push:
let myVariable
console.log(myVariable)
This is sometimes done when a variable does not have a value when
you declare it but may be assigned a value later on in the code. When
many variables need to be declared without values, they can be
separated by commas. In the following example, we define three
variables with the let keyword:
Assignment Operators
Now that we’ve covered the basics of setting variables, let’s look at
assignment operators. These allow us to modify an existing variable, by
changing its value. For example, consider this variable:
let x = 5
let x = 5
x *= 5
console.log(x) // Console logs 25 (5 multiplied by
5 = 25)
There are many other assignment operators. They are shown in the
following example:
let x = 5
x *= 5
console.log(x) // Console logs 25 (5 multiplied by
5 = 25)
x += 5
console.log(x) // Console logs 30 (25 plus 5 = 30)
x /= 5
console.log(x) // Console logs 6 (30 divided by 5
= 6)
x -= 1
console.log(x) // Console logs 5 (6 minus 1 = 5)
x %= 4
console.log(x)
/*
Console logs 1 (if you divide 5 by 4, the
remainder is 1.
% is the remainder operator
*/
Variable Concatenation
When we have variables that consist of at least one string, using the +
operator causes the strings to become concatenated. To understand
this, take a look at the following example, where we concatenate two
strings into a new variable:
// "hello world"
let combine = myVariable + " " + myOtherVariable
Just be careful, since if you try to use a + with numbers, it will add
them up instead!
let myVariable = 5
let myOtherVariable = 5
Template Literals
Another final way to concatenate more elegantly is through a type of
functionality called template literals. Template literals are still strings,
but they use the backtick "`" to transform any content into a template
literal. Template literals have the added benefit of allowing line breaks
– something that numbers and quotation marks do not. They also allow
for substitution. Here is an example of a particularly messy template
literal with line breaks throughout:
JavaScript Comments
You may have already noticed that in the preceding code, I used double
slashes to leave some comments on what the code does. As our code
gets more complicated, it’s useful to leave messages to yourself or other
developers about what is going on. For this purpose, comments are
used.
A comment in JavaScript can take one of two forms. The first looks
like this:
// I am a comment!
And the second looks like this, where the comment is enclosed in /*
and */:
/* I am a comment! */
Both work the same, but the second allows for multiline comments.
Comments have no bearing on the functionality of your code and
instead can provide useful information on what’s going on. For
example, we could comment our previous code like so:
Logical Statements
Now that we’ve covered variables, you’ll probably be wondering how
we can use them. Logical statements are one of the ways we can start to
put our variables to good use.
Logical statements are used when we want to check if something is
true or false and then run a particular action based on that outcome. If
a logical statement is found to be true, everything within its “block
scope” is executed. Likewise, if a logical statement is false, then the
block scope will never run at all. In other words, logical statements
allow us to build conditionality into our programs.
If…else Statements
if...else are perhaps one of the most commonly used logical
statements around. All they do is check if a statement is true. If it is,
they run some code, else, they run some other code. In the following
example, we check if myVariable is set to 5. If it is, we show “The
variable is 5!” in the console. If it’s not, then we show alternative text.
You can view this code running in Figure 2-4, where I run it directly
from the console in my web browser. You could also try this out by
updating your index.js file from earlier:
if(myVariable === 5) {
console.log("The variable is 5!")
}
else {
console.log("The variable is not 5.")
}
Figure 2-4 Since myVariable is 5, the statement myVariable === 5 is always true. So the
block of code within the first if statement is executed, and the else statement never fires
if(myVariable === 5) {
console.log("The variable is 5!")
}
else if(myVariable === 6) {
myVariable = 7
console.log("The variable is 6, but I set it
to 7!")
}
else {
console.log("The variable is not 5.")
}
As you can see in the else if condition, any code can be written
in the block scope created by a logical statement. In else if, we
reassigned myVariable to have a value of 7.
If the output of an if statement is one line of code, you can omit the
curly brackets and write it all on one line of code as shown in the
following example. This also applies to else if and else:
Switch Statements
Another common way to create conditionality in your JavaScript is
through switch statements. They take a single variable and check if it
equals certain values using the case keyword to define the value it
might equal and a break to declare the end of that clause. For
example:
// Let's set x to 5
let x = 5
switch(x) {
case 5:
console.log("hello")
break
case 6:
console.log("goodbye")
break
}
// Let's set x to 5
let x = 5
switch(x) {
case 4:
console.log("4!")
case 5:
console.log("hello")
case 6:
console.log("goodbye")
}
Figure 2-5 Since we didn’t use the keyword “break” in the preceding code and x is equal to 5,
both “hello” and “goodbye” are console logged. The “break” keyword is important for declaring
the end of a clause in a switch statement.
let x = "Apples"
switch(x) {
case "Apples":
case "Strawberries":
console.log("Apples and Strawberries can
be red.")
break
case "Bananas":
console.log("Bananas are yellow.")
}
// Let's set x to 5
let x = 5
switch(x) {
case 4: {
console.log("hello")
break
}
default: {
console.log("goodbye")
break
}
}
// Let's set x to 5
let x = 5
switch(x) {
case "5": {
console.log("hello")
break
}
case 5: {
console.log("goodbye")
break
}
}
// Let's set x to 5
let x = 5
switch(x) {
case 5:
let x = 6
console.log("hello")
break
case 6:
let x = 5
console.log("goodbye")
break
}
// Let's set x to 5
let x = 5
switch(x) {
case 5: {
let x = 6
console.log("hello")
break
}
case 6: {
let x = 5
console.log("goodbye")
break
}
}
let x = 5
if(myVariable === 5)
switch(variable)
That means both the value and the type of data have to match for
the statement to be true. For example, '5' is not the same type as 5
even though the values are the same since the types are different:
let myVariable = 5
if(myVariable === 5) // True!
if(myVariable === "5") // False!
Besides strict equality, there are lots of other ways we can compare
data in logical statements. In the following example, we use the more
than operator to check if myVariable is more than specific values. The
outcome of this code can be seen in Figure 2-6.
let myVariable = 5
if(myVariable > 4) console.log("Hello World") //
True!
if(myVariable > 6) console.log("Hello World 2!")
// False!
Figure 2-6 Other operators can be used to test logical statements. In the preceding example,
we use the more than operator to check if myVariable meets certain conditions
We can check for “regular” equality too, which ignores type, using
the double equals (==) operator:
let myVariable = 5
if(myVariable == '5') // True!
“Kiuj?”
Magalhaes eĉ ne palpebrumis.
“Sidiĝu,” li diris trankvile. Nur kiam ili sidiĝis, li demandis: “Kaj kio
estas la kaŭzo de via deziro?”
“La perditaj jaroj signifas nenion en tiu kazo, se temas pri vivo de
homoj,” oponis energie la oficiro.
“Vi mem scias, sinjoro admiralo, kiom da viroj jam mortis kaŭze de
suferoj. Kaj vi povas imagi al vi, kio atendus nin dum plua veturo.”
“Mi scias tion. Kaj ĵus pro tio mi ordonis la dumvintran restadon. Ĉi
tie ni pasigos la plej malbonajn monatojn, kaj ĝis venos pli varma
vetero, ni veturos antaŭen.”
“Tio ne estas ebla, sinjoro admiralo,” rezistis la oficiro. “Ni venas por
peti vin, ke vi ordonu reveturon.”
Subita ideo heligis vizaĝon de Fernao. Jes, li faros tion! Nova sciigo
al ĉiuj ŝipoj: “Morgaŭ — la Paskan Dimanĉon — oni celebros sur la
bordo solenan meson. Poste sekvos revizia parado, kiun partoprenos
ĉiuj maristoj, oficiroj kaj kapitanoj.”
La fluso ĵetis sur la bordon ondojn kaj frakasis ilin kun malhela bruo.
Krom tio estis trankvile. La birdo ne ekkantis, la arbo ne ekmoviĝis,
ĉar ĉi tie ne estis arboj, kaj ankaŭ homoj silentis.
Kapitanoj?
“Mi ne scias.”
“Ne.”
“Jen...!”
La vorteto “Jen!” estis elparolita kun nuanco de amareco. Sed Fernao
Magalhaes estis forĝita el malmola ŝtalo. Apenaŭ li konsciiĝis pri la
monstra grandeco de nova disreviĝo, li tuj fariĝis la estinta Fernao.
Malmola, decidema, necedema. Li tuj rekonsciiĝis, kaj tiel okazis, ke
la vorto “Jen!” sonis kvazaŭ malhela minaco.
Ĉu ribelo?
Estu! Eble estas pli bone tiel, se oni batalas kun malfermita viziero.
Ĝi ja kuŝis sur la ekspedicio kiel premeganta inkubo tuj de la
komenco — de la kolerigitaj homamasoj en Sevilo ĝis la hieraŭa
deputacio. Estos bone, se ĉio klariĝos.
Kaj ribelo en ĉi tiu dezerto povas finiĝi per neniigo kaj ruinigo de la
tuta ekspedicio.
XII.
Ribelo
Mesquita pensis pri sia ŝipanaro sur San Antonio. Li ja estis kapitano
nur ekde la restado en Brazilio, sed dum tiu tempo li lernis koni sian
ŝipanaron ĝis tia grado, ke li povu taksi, kiun li povas konfidi, kiun li
devas malkonfidi. La plej sindona estas certe Eloriago. La malmilda
maristo, kiu plenumas ĉiujn taskojn kun modela konscienco. Se
ceteraj murmuras pro io, li ĉiam scipovas trankviligi ilin. Kaj ne per
longaj paroloj. Iam li nur svingas per la mano kaj eklaboras, aliokaze
li diras trafan spritaĵon — maristoj ekridas kaj sekvas lin. Estas tie
kelkaj viroj, kiujn li povus konfidi en kazo de eventuala konflikto. Sed
la plejmulto?
Do, ĉi tio estus unu parto, meditas Fernao. La duan parton faras lia
Trinidado. Santiago de Serrao kaj San Antonio de Mesquita.
Tri kontraŭ du, finas sian revizion admiralo. Eĉ se Santiago kaj San
Antonio estas pli malgrandaj karaveloj, finfine ĉi tie decidas la
nombro, la kapableco de pli moviĝema manovrado. Do situacio ne
aspektas iel senesperige. Eble eĉ nenio okazos. Povas esti, ke la
hidalgoj en dormo forgesos sian malpraviĝon kaj matene venos por
peti senkulpigon.
“Bravaj maristoj!” li alparolis ilin flate. “Mi volas danki al vi por ĉiu
laboro, kiun vi ĝis nun faris en servoj de la reĝo, kaj ankaŭ por ĉiuj
penoj, kiujn vi suferis. Veturante suden vi atingis tiel malproksimajn
landojn, kiujn atingi sukcesis neniu hispana ŝipo. Ĝis ni revenos
hejmen, la reĝo certe laŭ merito rekompencos viajn heroajn farojn.
Vi faris jam pli ol vian devon kaj nun venis tempo por reveturi
hejmen.”
La voĉo apartenis al dua ŝipoficiro Lopez, kiu klare komprenis, pri kio
ĉi tie temas.
“Ne aŭskultu lin!” li diris al ceteraj maristoj. “Tro baldaŭ li konos, kiel
li eraris. Mi sciigas al vi, ke en plena konfido je feliĉa reveturo mi
permesas hodiaŭ al la tuta ŝipanaro formanĝi tiom da nutraĵoj kaj
eltririki tiom da vino, kiom al ĉiu plaĉas!”
“Mi povas tie ankaŭ orientiĝi!” brulis batalavide Coca. “Mi kredas, ke
mi estos ĉe tiu amuzo ankaŭ iomete utila.”
Pli frue, ol patrolo sur San Antonio povis fari alarmon, ĝi estis
silentigita. Poste la konspirantoj sen malhelpaĵoj penetris en
subferdekon.
La tuta atako okazis rapide kaj senbrue. Ununura, kiu volis defendi
sin, estis Eloriago.
“Kiel mi konas lin,” respondis Elcano, “li ne rezignos sen batalo. Laŭ
mia opinio estus pli bone ne atendi, sed komenci tuj.”
“Atendu,” postulis ilin Fernao. “Mi tralegos ĝin kaj mi tuj donos
respondon al vi.”
Ribelantaj kapitanoj komunikis al admiralo, pri kio ili decidiĝis kaj kio
dumnokte okazis. Kio kapitanon Mesquita koncernas, li povas esti
senzorga, ĉar tiu estas bone sekurita. La admiralo povos resti en sia
rango, sed venonte li devos agi laŭ deziro de plejmulto da oficiroj kaj
kapitanoj. La decido de ŝipanaro estas firma: reveno hejmen. La
supereco de kapitanoj estas tiom granda, ke estus tute sensenca
komenci fratomurdan batalon, kapitanoj esperas, ke admiralo
komprenos iliajn farojn kaj agos laŭ ilia deziro.
“Eloriago.”
“Ĉi tiujn virojn sekurigu,” li diris. “Kaj ilian boaton alligu al Trinidado.”
La ordono estis tuj plenumita.
Ankaŭ ĉi tiu dua atako estis tiom neatendita, ke la maristoj tuj perdis
ĉiun kuraĝon. Ili rapide forĵetis armilojn kaj falis sur genuojn. Post
kelkaj momentoj ili estis katenitaj.
Sed la ŝipoj de ribelantoj faras nek plej etan movon. La kapitanoj kaj
ceteraj maristoj, kiuj jam vidis admiralon sur genuoj, estas
mortpalaj. Lia nekredebla aŭdaco, kiun li montris atakinte dum hela
tago, plenumis ilin per konsterniĝo. Senmove kiel statuoj ili observis
lertan manovradon de admiralaj ŝipoj. Konfuzita Cartagena forsendis
Quesedon sur San Antonion, ke li tie helpu al Elcano gvidi la batalon.
Tri kapitanoj kaj kvindek maristoj, kiuj subiĝis al iliaj allogoj, atendis
en katenoj verdikton. Ili sciis, ke ĝi estos senkompata. La leĝoj de
oceanoj, kie interrilatoj de homoj estas multe pli respondecaj ol tiuj
sur la kontinento, estas malmildaj. La ribelon sur la maro oni punis
per la morto — tion sciis ĉiu marista lernanto. Ĉu admiralo ordonos
senkapigi ĉiujn ribelintojn, tio signifas kvinonon de la ekspedicio?
Cartagena kaj la ribelinta pastro estis punitaj plej kruele. Ĝis finiĝos
la dumvintra restado kaj ekspedicio estas preparita por forveturi, ili
estos transportitaj sur la bordon kaj lasitaj en la dezerta regiono por
malrapide morti.
Maristoj estis punitaj malpli severe. Admiralo rigardis ilin kiel
delogitajn viktimojn. Dum tiu tempo, kiam la ekspedicio restos en la
haveno, ili laboros en la ĉenoj. La katenoj estos al ili demetitaj nur
tiam, kiam la ekspedicio daŭrigos pluan veturon.
XIII.
Trapasejo
Des pli peniga ĝi estis por ekspedicio de Magalhaes, kiu faris ĝin en
libera naturo, sen ŝipkonstruejoj, nur per la plej necesa ilaro. Kaj ĝi
estis des pli peniga pro la kruelaj frostoj kaj sovaĝaj neĝblovadoj. Al
viroj frostis la manoj dum la laboro. Akraj glacipingloj pikis ilin en
vizaĝon. Grandaj neĝflokoj blindigis iliajn okulojn.
Ĉ
Ĉi tie, en sudamerika golfo de San Julian, la ŝipanaro vidis bone, ke
en frunto de ekspedicio staras viro, kiu estas eminenta spertulo sur
la maro kaj pri ĉio, kio koncernas la vivon sur ĝi. Homoj sur
Trinidado sciis tion jam longe. Sed ceteraj maristoj komencis valorigi
liajn kapablecojn nur nun, kiam ili havis eblon vidi lin ĉiutage
laboranta. Neniu ordono de admiralo devis esti pli poste ŝanĝata aŭ
revokata. Ĉiu estis klara, fiksa kaj preciza, kvazaŭ li pripensus ĝin
duontagon, kaj tamen li donadis ilin tuj sur la loko, laŭ la bezono.
Por ĉi tiu veturo estis destinita Serrao kun sia ŝipo Santiago.
Magalhaes konfidis lin plej multe el ĉiuj kapitanoj.
“Kie?”
“Proksime ĉe la haveno!”
“Jes!”
“Tio estas stranga,” skuis per kapo admiralo. “Kiomfoje ni jam serĉis
indiĝenojn, sed ĉiun fojon sen sukceso. Ĉu la maristoj ne eraris? Ĉu
ĝi ne estas postsigno de iu el niaj homoj, kiu tien erariris?”
Sed kiam li venis al la loko, li ĉesis ridi. La postsigno estis vere tiom
granda, ke similan li ankoraŭ neniam vidis.
“Ne,” respondis ĥore maristoj, kiuj intertempe ĉi tie ariĝis. Sed jam la
sekvantan tagon ili malkovris pluajn postsignojn. Kaj ĉiuj estis tiel
nenormalaj, grandegaj.
Patagoniano!
“Garcia, iru al li kaj faru la samajn movojn kiel li,” li diris. “Tiel li
scios, ke vi venas kiel amiko.”
Garcia ne lasis sin dufoje instigi. Li malgracie saltetis kaj per fortega
baritono li kantis ian kanteton. La maristoj ridis pri liaj groteskaj
movoj ĝis ili larmis.
Patagoniano komprenis. Kaj Garcia ne bezonis tro peni por alkonduki
lin en la havenon.
“Sinjoro admiralo, rigardu!” li vokis. “Ja tiu homo havas sur la piedoj
tutajn boatojn! Nun mi jam komprenas!”
Ĉi tiu bona humoro estis subite interrompita per sciigo, kiu efikis kiel
batego de la tondro.
Kiuj povas ili esti? Patagonianoj tio ne estas — kaj de kie venus en ĉi
tiun forgesitan landon aliaj homoj?
Sed li mem tuj rapidis al la venantaj maristoj. Kaj jam ili estis tiom
proksime, ke li distingis ilin: la dua ŝipoficiro Lopez kaj ŝipgvidisto
Barnolas.
“Nia ŝipo averiis, sinjoro admiralo,” diris per malforta voĉo Barnolas.
“Kaj maristoj?”
“Savitaj.”
“Ĉu ĉiuj?”
“Jes.”
“Dank’ al dio!” respiris admiralo, kiu jam komencis timi la plej
malbonon.
Dek unu tagojn! Dek unu tagojn tra la dezerta kaj nepriloĝata
regiono! Dek unu senfinajn noktojn en frostaj neĝamasoj!
Kaj —?”
ebookbell.com