Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
21 views

Learning JavaScript Data Structures and Algorithms Write complex and powerful JavaScript code using the latest ECMAScript 3rd Edition Loiane Groner 2024 Scribd Download

The document promotes various eBooks available for download on ebookmeta.com, focusing on topics like JavaScript data structures and algorithms, behavior-driven development, and other programming and economic subjects. It highlights the benefits of subscribing to Mapt for access to a vast library of digital resources. Additionally, it includes information about the authors and contributors of the featured books.

Uploaded by

rasanlandtc4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
21 views

Learning JavaScript Data Structures and Algorithms Write complex and powerful JavaScript code using the latest ECMAScript 3rd Edition Loiane Groner 2024 Scribd Download

The document promotes various eBooks available for download on ebookmeta.com, focusing on topics like JavaScript data structures and algorithms, behavior-driven development, and other programming and economic subjects. It highlights the benefits of subscribing to Mapt for access to a vast library of digital resources. Additionally, it includes information about the authors and contributors of the featured books.

Uploaded by

rasanlandtc4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Learning JavaScript Data Structures and Algorithms


Write complex and powerful JavaScript code using
the latest ECMAScript 3rd Edition Loiane Groner

https://ebookmeta.com/product/learning-javascript-data-
structures-and-algorithms-write-complex-and-powerful-
javascript-code-using-the-latest-ecmascript-3rd-edition-
loiane-groner/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Learning Behavior driven Development with JavaScript


Create powerful yet simple to code BDD test suites in
JavaScript using the most popular tools in the community
1st Edition Enrique Amodeo
https://ebookmeta.com/product/learning-behavior-driven-development-
with-javascript-create-powerful-yet-simple-to-code-bdd-test-suites-in-
javascript-using-the-most-popular-tools-in-the-community-1st-edition-
enrique-amodeo/
ebookmeta.com

JavaScript Data Structures and Algorithms: An Introduction


to Understanding and Implementing Core Data Structure and
Algorithm Fundamentals 1st Edition Sammie Bae
https://ebookmeta.com/product/javascript-data-structures-and-
algorithms-an-introduction-to-understanding-and-implementing-core-
data-structure-and-algorithm-fundamentals-1st-edition-sammie-bae/
ebookmeta.com

JavaScript Regular Expressions Leverage the power of


regular expressions to create an engaging user experience
1st Edition Loiane Groner Gabriel Manricks
https://ebookmeta.com/product/javascript-regular-expressions-leverage-
the-power-of-regular-expressions-to-create-an-engaging-user-
experience-1st-edition-loiane-groner-gabriel-manricks/
ebookmeta.com

OCP Java SE 8 Programmer II Exam Guide Exam 1Z0 809 Kathy


Sierra Bert Bates Elisabeth Robson

https://ebookmeta.com/product/ocp-java-se-8-programmer-ii-exam-guide-
exam-1z0-809-kathy-sierra-bert-bates-elisabeth-robson/

ebookmeta.com
Economics: Private & Public Choice 17th Edition James D.
Gwartney

https://ebookmeta.com/product/economics-private-public-choice-17th-
edition-james-d-gwartney/

ebookmeta.com

How to Develop a Profitable Trading Strategy 1st Edition


Heikin Ashi Trader

https://ebookmeta.com/product/how-to-develop-a-profitable-trading-
strategy-1st-edition-heikin-ashi-trader/

ebookmeta.com

A History of Cant and Slang Dictionaries Vol 4 1937 1984


Julie Coleman

https://ebookmeta.com/product/a-history-of-cant-and-slang-
dictionaries-vol-4-1937-1984-julie-coleman/

ebookmeta.com

The New Atlantic Order The Transformation of International


Politics 1860 1933 1st Edition Patrick O. Cohrs

https://ebookmeta.com/product/the-new-atlantic-order-the-
transformation-of-international-politics-1860-1933-1st-edition-
patrick-o-cohrs/
ebookmeta.com

Pergamonmuseum Berlin. Collection of Classical


Antiquities, Museum of the Ancient Near East, Museum of
Islamic Art 5th Edition Martin Maischberger
https://ebookmeta.com/product/pergamonmuseum-berlin-collection-of-
classical-antiquities-museum-of-the-ancient-near-east-museum-of-
islamic-art-5th-edition-martin-maischberger/
ebookmeta.com
Dragonbane Were Hunters 08 Dark Hunter 24 Hellchasers 07
Hunter Legends 27 Lords of Avalon 04 1st Edition Sherrilyn
Kenyon
https://ebookmeta.com/product/dragonbane-were-hunters-08-dark-
hunter-24-hellchasers-07-hunter-legends-27-lords-of-avalon-04-1st-
edition-sherrilyn-kenyon/
ebookmeta.com
Learning JavaScript Data Structures and Algorithms
Third Edition

Write complex and powerful JavaScript code using the latest


ECMAScript

Loiane Groner
BIRMINGHAM - MUMBAI
Learning JavaScript Data
Structures and Algorithms
Third Edition
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty, either express or implied. Neither the author,
nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been
caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy
of this information.

Commissioning Editor: Amarabha Banerjee


Acquisition Editor: Larissa Pinto
Content Development Editor: Flavian Vaz
Technical Editor: Vaibhav Dwivedi
Copy Editor: Safis Editing
Project Coordinator: Devanshi Doshi
Proofreader: Safis Editing
Indexer: Rekha Nair
Graphics: Jason Monteiro
Production Coordinator: Arvindkumar Gupta

First published: October 2014


Second edition: June 2016
Third edition: April 2018

Production reference: 1250418

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78862-387-2
www.packtpub.com
To my parents, for their love and support and for guiding me throughout all these years.
To my husband, for his support and for being my loving partner throughout our life journey.
– Loiane Groner
mapt.io

Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


PacktPub.com
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to
the eBook version at www.PacktPub.com and as a print book customer, you
are entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical


articles, sign up for a range of free newsletters, and receive
exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Loiane Groner has over 10 years of experience in developing
enterprise applications. Currently, she works as a business analyst
and a Java/HTML5/JavaScript developer at an American financial
institution.

She is passionate about technology, publishes articles on her blog,


and has presented talks at conferences about Java, ExtJS, Cordova,
Ionic, TypeScript and Angular.

She is a Google Developer Expert in Web Technologies and Angular,


and a Microsoft Most Valuable Professional in Visual Studio and
Development Technologies. She has also authored other Packt
books.
I would like to thank my parents, for giving me education, guidance, and advices through all these years, and my
husband, for being patient and supportive and giving me encouragement so that I keep doing what I love.
I also would like to thank the readers of this book and other books that I have written for their support and feedback.
Thank you very much!
About the reviewers
Todd Zebert is a full stack web developer, currently at Miles.

He has been a technical reviewer for a number of books and videos,


is a frequent presenter at conferences on JavaScript, Drupal, and
related technologies, and has a technology blog on Medium.

He has a diverse background in technology, including infrastructure,


network engineering, PM, and IT leadership. He started web
development with the original Mosaic browser.

He is an entrepreneur and part of the LA start-up community. He


believes in volunteering, Open Source, Maker/STEM/STEAM, and
contributing back to the community.

Kashyap Mukkamala is a passionate software architect at Egen


Solutions Inc. and the author of Hands-On Data Structures and
Algorithms with JavaScript. When Kashyap is not solving problems
for Fortune 500 companies at Egen, he is focused on building the
web of the future and helping the community grow and learn.
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit author
s.packtpub.com and apply today. We have worked with thousands of

developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a general
application, apply for a specific hot topic that we are recruiting an
author for, or submit your own idea.
Table of Contents
Title Page
Copyright and Credits
Learning JavaScript Data Structures and Algorithms  Third Edition
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
1. JavaScript – A Quick Overview
JavaScript data structure and algorithms
Setting up the environment
The minimum setup to work with JavaScript
Using web servers
Node.js http-server
JavaScript basics
Variables
Scope variable
Operators
Truthy and falsy
Functions of the equals operators (== and ===)
Control structures
Conditional statements
Loops
Functions
Object-oriented programming in JavaScript
Debugging and tools
Debugging with VSCode
Summary
Another Random Document on
Scribd Without Any Related Topics
The Hull of the Houseboat is Built on the Scow Type so That It can be Run in
Shallow Water without Danger

Two wide bunks, beneath which is locker space, provide sleeping


accommodations for a crew of four. In the kitchen the motor and
gearing are almost completely concealed under the work table. The
cooking is done on a two-burner blue-flame kerosene stove, and the
sink is provided with running water suitable for washing dishes, etc.
This water is drawn from a 30-gal. tank on the roof, which is filled by
a centrifugal pump driven from the engine shaft. A modern toilet
room is installed, and an ice chest on the after deck will hold
supplies and ice for a week’s cruise.
Detail of the Anchor Windlass and Engine Gearing; Also the Deck Plan,
Showing the Location of the Parts and the Arrangement of the Cabins

An acetylene-gas lighting system is installed and is used to light


both cabins and a searchlight. A heavy anchor of special design is
manipulated by a windlass on the forward deck. A similar device
controls the rudder. Life rafts, complete with paddles, are placed on
the roof, and in hot weather these are moved to one end and an
awning erected to make a cool sleeping place.
Wood Box with a Refuse-Catching Drawer

The Wood Receptacle Has a Drawer Bottom for Catching the


Dirt, Which can be Easily Cleaned

The ordinary wood box may be greatly improved by adding a


drawer at the top and one at the bottom, as shown in the sketch. The
upper drawer is used for storing the flatirons and stove-polishing
materials, and the lower drawer is the bottom of the wood box. The
dirt and pieces falling from the wood remain in the drawer, which can
be removed and cleaned easily.—Contributed by William Jutila,
Astoria, Ore.
Disappearing-Coin Trick
To make a quarter disappear from a glass of water after hearing it
drop is a very puzzling trick. The articles necessary to perform this
trick are a glass of water, a handkerchief, a quarter and a piece of
clear glass the exact size of a quarter. The glass can be cut and
ground round on an emery wheel, and the edge polished.
To perform the trick advance with the piece of glass hidden
between the second and third fingers of the left hand and holding the
quarter in plain sight between the thumb and first finger of the same
hand and the handkerchief in the right hand. Throw the handkerchief
over the left hand and gather up the glass piece in the fold of the
cloth, allowing the coin to drop into the palm of the left hand while
covered. Remove the left hand and hold out the piece of glass with
the handkerchief drawn tightly around it. Anyone can touch the cloth-
covered glass, but it cannot be distinguished from the quarter. While
this is being shown slip the quarter into a pocket. Spread the
handkerchief over the glass of water and allow the glass disk to
drop. A distinct click will be heard when it strikes the bottom. Raise
the handkerchief and nothing will be seen, as the glass will not be
visible in the water.—Contributed by Amon H. Carr, Gainesville, Tex.
Watering Window-Box Flowers

The Soil is Kept Moist by the Water Feeding through the Sponges from the
Under Side

The window box for flowers can be conveniently watered in the


following manner: Construct a metal box to receive the box holding
the soil and bore enough holes in its bottom to admit water to the
soil. The inside box should be supported about 2 in. above the
bottom of the metal box. Sponges are placed in the bottom to
coincide with the holes in the soil box. A filling tube is made at the
end. The water is poured into the metal box and the sponges admit
only enough water for the plants at all times.
How to Make Combined Kites
By C. M. MILLER

PART I—A Dragon Kite

Dragon kites are made as hideous as the maker can possibly


conceive, and while the one to be considered is no beauty, it is
more droll than fierce-looking. In general appearance the dragon and
centipede kites are like huge caterpillars floating about in the air. The
kite sometimes twists and the balancer sticks appear to be large
hairy spines. Usually the tail end swings higher than the head. It is
like so many single kites, pulls hard, and requires a strong cord for
the line. The individual circular sections may number 20, and if
placed 30 in. apart, would make a kite about 50 ft. in length, or the
number of sections may be more or less to make it longer or shorter.
The kite will fold up into a very small space, for carrying about or for
storage, but care should be taken in folding not to entangle the
harness.
In General Appearance the Dragon Kite Is Like a Huge Caterpillar Floating
About in the Air

The Head

The head requires much more work than any of the other sections.
There are two principal rings to this section, as shown in Fig. 1. The
inner ring is the more important, the outer one being added for the
protection of the points when alighting. The construction of the
framework is shown in Fig. 2. It is made entirely of bamboo. The
bamboo is split into strips, about ³⁄₁₆ in. wide, for the ring A. As the
bamboo strips will be much too thick, they must be pared down to
less than ¹⁄₁₆ in. The diameter of the ring A is 12 in., and a strip of
bamboo to make this ring should be about 38 in. long, so that there
will be some end for making a lap joint. The ends of the strip are held
securely together by winding them with linen thread. The Chinese
boys use strips of rice paper, about ¹⁄₂ in. wide and torn lengthwise of
the paper. The rice-paper strips are made wet with paste before
winding them on the joint, and when they dry out the shrinkage will
bind the ends securely.
Two crosspieces, of the same weight as the ring stick, are placed
3¹⁄₂ in. apart, at equal distances from the center and parallel, as
shown at B and C. The ends of these pieces are turned at a sharp
angle and lashed to the inside surface of the ring A. To make these
bends, heat the bamboo over a candle flame until it will give under
pressure, then bend and it will stay in shape after it becomes cold.
This method of bending should be remembered, as it is useful in
making all kinds of kites. Two small rings, each 3¹⁄₂ in. in diameter,
are put in between the two parallel pieces, as shown at D and E.
These are for the eyes of the dragon. The rings are lashed to the two
crosspieces B and C. As the eyes revolve in the rings they should be
made perfectly true. This can be done by shaping the bamboo about
a perfectly round cylinder, 3¹⁄₂ in. in diameter. To stiffen the whole
framework, two pieces of bamboo, ¹⁄₁₆ in. thick, ¹⁄₈ in. wide, and 20
in. long, are lashed to the back as shown by F and G. There is a
space of 3 in. between the inner ring A and the outer ring H, giving
the latter a diameter of 18 in. It is made of a bamboo strip, ¹⁄₈ in.
wide, and should be less than ¹⁄₁₆ in. thick. It may be necessary to
make this large ring from two pieces of bamboo, to get the length,
and in such case be careful to make a perfect ring with the ends well
lashed together. Two short pieces are lashed to the two rings, as
shown at J and K. The supports for the horns consist of two pieces,
¹⁄₈ in. wide and less than ¹⁄₁₆ in. thick, and they are lashed to the
upper crosspiece and to both rings, so that the parts L and M are
exactly halfway between the ends of the pieces F and G and radiate
out from the center of the ring A, the other parts, N and O, pointing to
the center of the eye rings, respectively. The ears are unimportant
and may be put on if desired. The rings on the horns and the stick
ends may be from ¹⁄₂ to 2 in. in diameter, cut from stiff paper, but if
larger, made of bamboo.

Fig. 1 Fig. 2
The Kite-Head Section, Having Horns, The Framework for the Head Section
Ears, and Revolving Eyes, Is Very is Made Entirely of Bamboo Strips
Hideous Lashed at the Joints

Chinese rice paper is the best material for covering, and it should
be stretched tightly so that there will be no buckling or bagging
places. The only part covered is that inside of the inner ring A, the
horns, and the ears, leaving the eye rings open. The shades are put
on with a brush and water colors, leaving the face white, or it can be
tinted in brilliant colors. Leave the horns white and color the tongue
red.
The Eyes

The frame for each eye is made of bamboo, pared down to ¹⁄₃₂ in.
in thickness and formed into a perfect ring, 3¹⁄₄ in. in diameter. Each
ring revolves on an axle made of wire passed through the bamboo
exactly on the diameter, as shown at P, Fig. 3. The wire should be
long enough to pass through the socket ring D or E, Fig. 2, also, and
after the eye ring is in place in the socket ring and the axle adjusted,
the latter is fastened to the eye ring with a strip of paper wrapped
tightly around the wire and pasted to the bamboo of the ring. A glass
bead, placed on the wire axle between the socket rings D or E and
the eye ring Q on each side, keeps them apart and the revolving one
from striking the other.
Each side of the eye ring is covered halfway with rice paper, as
shown in Fig. 4. The part R is on the upper front half, and that shown
by S is on the back lower half. Placing the two halves in this manner
causes an unequal pressure of the wind on the whole eyepiece, and
thus causes it to revolve on the axle. The front upper half of the
eyepiece is made black, and the smaller dark portion extending
below the darkened half is a round piece of paper placed just
between the two halves so that half of it will show on both front and
back of the eyepiece. When the eyepiece is given a half turn in its
socket the back side will come to the front and will appear just the
same as the other side. Some kite builders add pieces of mirror
glass to the eyes, to reflect the light and cause flashes as the eyes
revolve in their sockets.

A Section Kite

The ring for the section kite is made the same size as the inner
ring of the head kite, or in this case 12 in. in diameter. The bamboo
for making this ring should be ¹⁄₈ in. wide and ¹⁄₁₆ in. thick. The
balancer stick, 36 in. long, is located about the same place as the
cross-stick F, as shown in Fig. 2, and must be made small, light and
well balanced. Small tufts of tissue paper, or feathers, are attached
to the tip ends of the balancer sticks, as shown in Fig. 5. The cover
for the section kite is put on tightly, the same as for the head, the
colors indicated in the sketch being only suggestions, as the builder
can color them as desired. The balancer on the last section should
have streamers, as shown in Fig. 6, for a finish. The streamers are
made of light cloth.

Fig. 3 Fig. 4

Two Bamboo Rings with Paper Coverings, to Make Them Turn in the Wind,
Constitute the Eyes
Fig. 6 Fig. 7
Fig. 8 Fig. 5

The Section Kites Have Balancers and the Disks are Given Bright Colors So
That They will Produce the Effect of a Great Dragon When in the Air, the
Head Piece Having a Ball Balancer Hanging from the Under Edge

The Harness

As previously stated, 20, more or less, sections can be used, and


the number means so many separate kites which are joined together
with three long cords, spacing the sections 30 in. apart. The cords
should be as long as the kite from the head to the tail, allowing
sufficient extra length for the knots. As such a kite will make a hard
pull, the cord used should be a six-ply, hard-twisted seine twine.
Start by tying the three long cords to the head kite at the points T, U,
and V, Fig. 2. Tie the next section at corresponding places just 30 in.
from the head kite. The construction will be much easier if the head
kite is fastened to a wall so that each cord may be drawn out to its
proper length. Continue the tying until all sections are attached just
30 in. apart. Other spacing can be used, but the distance selected
must be uniform throughout the length of the kite. The individual
kites, or sections, may vary in size, or they can all be 9 in. in
diameter, instead of 12 in., and the balancer sticks 30 in. long
instead of 36 in., but a kite of uniform sections is much better and is
easier to make. The positions of the sections as they will appear in
the kite are shown in Fig. 7.

The Bridle

The Chinese bridle is usually made of three strings, which are


attached to the same points on the head kite as the harness cords,
or at T, U, and V. The lower string is longer than the two upper ones
so that the proper inclination will be presented to the breeze. As the
head is inclined, all the section kites will also be inclined. Some
makers prefer a balancer on the head kite, and in one instance such
a balancer was made in the shape of a ball. A ball made of bamboo
strips is shown in Fig. 8, and is attached as shown in Fig. 7.

Flying the Kite

It will be necessary to have a helper, and perhaps two, in starting


the kite up, as the harness might become entangled. Quite a little run
will be necessary, but when up the kite will make a steady flier and
will pull very hard. If the first attempt is unsuccessful, try
readjustment of the bridle or a little different position in the breeze,
and see that the balancers are not tangled. Quite a number of
changes may be worked out on these plans, but it is necessary to
bear in mind that the distances between sections must be equal and
that the general construction must be maintained.
A Movable Sunshade and Seat for Garden
Workers

The Sunshade and Seat are Mounted on Wheels So That the Device can be
Easily Moved About

Weeding gardens under a hot sun and in a necessarily


uncomfortable position is by no means a pleasant occupation, but
much of the hardship can be avoided if a combination movable
sunshade and seat is made, as shown in the illustration. The
framework consists of two end pieces, both made in the same way.
Two ¹⁄₂-in. tees are required for each. These are connected with a 5-
ft. pipe, for the upright, and the crosspiece that supports one end of
the canvas consists of two pieces of pipe, each about 1¹⁄₂ ft. long,
screwed into the tee. The axle for the wheels is also formed of two
pieces of pipe, but these are only about 1 ft. long.
Four suitable cart wheels should be provided, or solid circular
disks cut out of a board or plank, and drilled for a ³⁄₈-in. axle.
Ordinary ³⁄₈-in. washers are placed on each side of the wheels, one
serving as a shoulder on the pipe end, and the other for the nut. The
seat can be made of a 1 by 8-in. board, about 6 ft. 9 in. long,
notched at each end to fit the pipe tees and prevented from shifting
by means of U-bolts around the axle on either side of the upright.
After covering the top with canvas, fastened at each end around the
upper crosspiece, the shaded movable seat is ready for service.—
Contributed by W. E. Crane, Cleveland, Ohio.
To Keep Grass and Weeds Out of Tennis Courts
Tennis courts are very apt to become covered with grass and
weeds unless considerable labor is expended on them. The best
way to keep a court free from this growth is to put on sheets of tar
paper close together when it is not in use. The paper should be cut
in strips the proper length, so that they can be rolled up and set
aside until the game is over, when they can be laid down again. After
the court has been covered a few times, the grass will die out and
disappear altogether. The use of salt, acids, and a number of other
things, together with hoeing, were tried out, but the paper covering
was the most successful of them all.—Contributed by W. D. Mills,
Bakersfield, Cal.
Buttonhole-Bouquet Holder to Keep Cut Flowers
Fresh
Being employed near a glass-blowing department I procured a
small glass tube and made a buttonhole-bouquet holder. One end of
the tube I closed and flared the other, then flattened the whole tube a
bit. This tube, inserted in the buttonhole with a few drops of water in
it, will keep cut flowers fresh for a whole day. If the upper end is
flared just right it will fit the buttonhole and will not be seen, as the
tube is hidden beneath the coat lapel.—Contributed by Frank Reid.

You might also like