Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning JavaScript Data Structures and Algorithms
  • Table Of Contents Toc
Learning JavaScript Data Structures and Algorithms

Learning JavaScript Data Structures and Algorithms - Fourth Edition

By : Loiane Groner
close
close
Learning JavaScript Data Structures and Algorithms

Learning JavaScript Data Structures and Algorithms

By: Loiane Groner

Overview of this book

Data structures and algorithms are foundational topics for software developers. This easy-to-follow book from experienced developer and trainer Loiane Groner will help you to fill in the gaps in your knowledge – whether you’re a self-taught developer, you’re preparing for technical interviews, or you just want to write better code and improve your problem-solving skills. This fourth edition covers essential data structures, algorithms, and their usage in the context of JavaScript. You’ll follow examples in both JavaScript and TypeScript, in line with the latest standards and best practices, learning how to do complexity analysis along the way. New to this edition are LeetCode and HackerRank exercises at the end of each chapter, which you'll be guided through solving. You’ll also find brand-new chapters on the tries data structure, and string and math algorithms. By the end of the book, you will know how to develop programs using the best data structures and algorithms for the job.
Table of Contents (9 chapters)
close
close
Lock Free Chapter
1
Learning JavaScript Data Structures and Algorithms, Fourth Edition: Enhance your problem-solving skills in JavaScript and TypeScript

Accessing elements and iterating an array

To access a specific position of the array, we can also use brackets, passing the index of the position we would like to access. For example, let's say we want to output all the elements from the daysOfWeek array. To do so, we need to loop the array and print the elements, starting from index 0 as follows:

for (let i = 0; i < daysOfWeek.length; i++) {
  console.log(`daysOfWeek[${i}]`, daysOfWeek[i]);
}

Let's look at another example. Suppose that we want to find out the first 20 numbers of the Fibonacci sequence. The first two numbers of the Fibonacci sequence are 1 and 2, and each subsequent number is the sum of the previous two numbers:

// Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
const fibonacci = []; // {1}
fibonacci[1] = 1; // {2}
fibonacci[2] = 1; // {3}
// create the fibonacci sequence starting from the 3rd element
for (let i = 3; i < 20; i++) {
  fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2]; // //{4}
}
//...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning JavaScript Data Structures and Algorithms
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon