1 min read 62 words Updated Oct 03, 2026 Created Oct 03, 2026
#JavaScript#review

Some JavaScript-specific Gotchas.

Some values are passed by reference

When passing this array, it is passed by reference, thus the original array can be altered in the function.

const people = ["Max", "Tom"];  
  
function alterPeople(peopleArr: string[]) {  
peopleArr.push(`Anna`);  
}  
  
alterPeople(people);  
console.log(people); // Max, Tom, Anna

This does NOT apply to primitives such as integers and also not to strings.