[Solved] When command line order matters?


When you do this:

var arrnew = [max, min, avg];

This places a copy of the contents of max, min, avg into the array. Future changes to what max, min and avg contain will not affect the array in any way.

So, if you do;

var max = 3, min = 1, avg = 2;
var arrnew = [max, min, avg];    // 3, 1, 2
max = 5;
console.log(arrnew);             // 3, 1, 2

Note, the contents of arrnew are not affected at all by subsequent changes to what max, min or avg contain. This is just how Javascript (and most languages work).

5

solved When command line order matters?