O'Reilly logo

Mastering JavaScript High Performance by Chad R. Adams

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

Array performance

We typically don't think about arrays when dealing with performance, but it's worth mentioning a few things here. First, large arrays can be messy and performance hogs when you're trying to work with a large amount of data. Typically with arrays, we only need to worry about two things: searching and array size.

Optimizing array searches

Let's create an array that has a lot of values in it; here I've created an array called myArray which has 1001 values within, with a string value of key and the index of the array. You can grab the full version in the 06_09.js file inside the Chapter_6 folder of the example code on the Packt Publishing's website. Here's a part of the code sample of the total array:

There are two ways to look up a ...

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