There are nine units in Lambda School’s Full Stack Web Development Pre-course. I’m going to summarize what the pre-course covers for each of them. This material is basically ground-floor information that students need to know before they start the full course.

Array Methods and Properties
As special objects in JavaScript, arrays have their own properties and methods. I’ve been unable to find a lot of information about array properties. From what I can see, there are not many of them. The ones I’ve come across so far are:
- constructor: returns a reference to the array function that created the object
- index: represents the zero-based index of the match in the string
- input: only present in arrays created by regular expression matches
- length: reflects the number of elements in an array (dynamically updates)
- prototype: allows addition of properties and methods to an object
I don’t quite grasp the usefulness of the constructor property yet. It seems like it just gives the name of the function that called it. Index is just the number of the given item in an array (since counting starts at zero, the actual position is one less than how we normally count when starting at one). Input basically confirms that a string or some other value is present in a given array. Length counts the number of items in an array and automatically updates if the array grows or shrinks. Finally prototype lets a programmer create a new property or method. This property or method can then be used with any array in a given program, so its kind of like writing a new function that can be used on all of the arrays in a program.
Like functions, arrays have their own built-in methods. Some of the following pages were shared in the last post, but they bear repeating as they detail many methods:
- w3schools: JavaScript Array Methods
- JavaScript.info: Array Methods
- dev.to: 10 JavaScript array methods you should know
- tutorialspoint: JavaScript – The Arrays Object
Array methods covered in the pre-course
A word of advice to students taking the pre-course and readying for the challenge at the end: go over array methods, and learn more about sorting methods, in particular. When I took the challenge, the questions that gave me the most difficulty all had to do with sorting arrays and inserting data into them at points that were NOT the beginning or end. These concepts are not covered in the pre-course, and I think are included to force potential students to learn on the spot and to use the internet to quickly find information to help pass the challenge.
.length
The .length method returns the number of items in an array:
const studentsNames = [‘Dan’, ‘Maria’, ‘Sara’, ‘Raj’]; console.log(studentNames.length); // 4
.push & .pop
These methods add items to an array and remove items from an array after it’s initial declaration, respectively.
.push adds an item to the end of the array, incrementing it’s length by 1. (.push returns the new length)
const studentsNames = [‘Dan’, ‘Maria’, ‘Sara’, ‘Raj’];
studentNames.push('Ryan');
console.log(studentNames); // ['Dan', 'Maria', 'Sara', 'Raj', 'Ryan']
.pop removes the last item in the array, decrementing the length by 1. (.pop returns the “popped” item)
const studentsNames = [‘Dan’, ‘Maria’, ‘Sara’, ‘Raj’]; studentNames.pop(); console.log(studentNames); // ['Dan', 'Maria', 'Sara']
.unshift & .shift
.unshift and .shift are exactly like .push and .pop, except they operate on the first item in the array. .unshift(item) will put a new item in the first position of the array, and .shift() will remove the first item in the array.
const studentsNames = [‘Dan’, ‘Maria’, ‘Sara’, ‘Raj’];
studentNames.unshift('Ryan');
console.log(studentNames); // ['Ryan', 'Dan', 'Maria', 'Sara', 'Raj']
studentNames.shift();
console.log(studentNames); // ['Dan', 'Maria', 'Sara', 'Raj']
Notes on Arrays
As per the Lambda School text:
Because Javascript is not a strongly typed language, arrays do not need to be typed either. Arrays in Javascript can contains multiple different data types in the same array.
2 thoughts on “Lambda School Pre-Course 17: Learn to use Array methods and properties”