JSE Certified Entry-Level JavaScript Programmer study materials
JSE Certified Entry-Level JavaScript Programmer study resources

JSE Certified Entry-Level JavaScript Programmer: Arrays and Objects

JSE Certified Entry-Level JavaScript Programmer · Work through your exam, one topic at a time.

All guide sections

Arrays and Objects

What this domain covers

Array methods and their mutation/return behaviour, plus object property access, copying, and comparison. Questions typically hand you a chain and ask for the resulting value or whether the original changed.

Array essentials

Arrays are zero-indexed objects with an auto-updating length. push/pop work at the end, unshift/shift at the start. slice returns a shallow copy; splice mutates and returns the removed items. includes uses SameValueZero (so it finds NaN), while indexOf uses strict equality (so it does not). forEach always returns undefined; map returns a new array of the same length; filter may shrink it; find returns a value; reduce folds with (accumulator, current, index, array).

Objects

Dot access needs a valid identifier; bracket access takes any expression. Objects are compared by reference, so {} === {} is false. Spread and Object.assign copy own enumerable properties shallowly - nested objects stay shared. Object.keys/values/entries return arrays; Object.hasOwn(obj, key) avoids inherited properties.

Worked example

const nums = [3, 10, 2];
nums.sort();
console.log(nums.includes('10'), nums.indexOf(2), nums);

Reasoning: sort() with no comparator converts elements to strings and orders them lexicographically, mutating in place → [10, 2, 3]. includes('10') compares strictly against the number 10, so it prints false. indexOf(2) finds the number at index 1. The final log shows [10, 2, 3]. Use nums.sort((a, b) => a - b) for numeric order.

Traps

  • [1, 2, 3].map(parseInt) gives [1, NaN, NaN] because map passes the index as the radix.
  • Assigning to arr.length truncates or pads the array.
  • delete arr[0] leaves a hole; it does not shorten the array.
  • const prevents rebinding, not mutation of an array or object.