console.log(arrayOfThings[1].name.length+4); // Logs 10

Amazing, right? We can continue to add on methods or properties at will to manipulate and change the request until we get back what we are looking for.

This is a core principle of JavaScript so it’s vitally important to understand this before moving on. Please do try this out for yourself in the console on Google Chrome. Play around with manipulating your response by adding on various properties, methods and so on to help yourself become more familiar with how it works.

Array methods and properties

Arrays, being objects (like almost everything is in JavaScript), allow us to make use of some built-in methods and properties. These methods can really help with how we make use of arrays. Let’s dive straight in.

Length property

This one we’ve seen before: it counts the number of characters in a string. So what do you think it will do on an array? You might assume that it will count the number of characters of all the strings inside the array. But that’s not quite right (largely because that wouldn’t be particularly useful), it simply counts how many items exist inside the array. Simple enough, but let’s see it in action: