Pass variables by reference in JavaScript

How do I pass variables by reference in JavaScript?

I have three variables that I want to perform several operations to, so I want to put them in a for loop and perform the operations to each one.

Pseudocode:

myArray = new Array(var1, var2, var3);
for (var x = 0; x < myArray.length; x++){
    // Do stuff to the array
    makePretty(myArray[x]);
}
// Now do stuff to the updated variables

What is the best way to do this?

17 Answers
17

Leave a Comment