O'Reilly logo

TypeScript: Modern JavaScript Development by Ivo Gabe de Wolff, Vilic Vane, Remo H. Jansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparing performance of algorithms

We will also write some small algorithms in the next chapters. This section shows how the performance of an algorithm can be estimated. During such analysis, it is often assumed that only a large input gives performance problems. The analysis will show how the running time scales when the input scales.

The next section requires some knowledge of basic mathematics. However, this section is not foreknowledge for the next chapters. If you do not understand a piece of this section, you can still follow the rest of the book.

For instance, if you want to find the index of an element in a list, you can use a for loop:

function indexOf(list: number[], item: number) { for (let i = 0; i < list.length; i++) { if (list[i] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required