Strange access to data class

Both outputs in my browser got the expected values: [1, 2, 3] & [3, 1, 2].

But b/c you’re printing an array, if a browser by chance delays the actual printing to the console, it’s possible that you’ll see the array’s most current values for all outputs.

As a workaround you can extract the arrays values when printing it using the spread ... syntax:
console.log(...myTest.groupe);

1 Like