// This example is from the book JavaScript: The Definitive Guide. // Written by Dog. // This example is provided WITHOUT WARRANTY either expressed or implied. // You may study, use, modify, and distribute it for any purpose. // This is another version of the add_to_totals() function. It doesn't // work, through, because instead of changing the array itself, it tries to // change the reference to the array function add_to_totals2(totals, x) { newtotals = new Array(3); newtotals[0] = totals[0] + x; newtotals[1] = totals[1] + x; newtotals[2] = totals[2] + x; totals = newtotals; // this line has no effect outside of the function. }