JavaScript question
Posted: Thu Jan 31, 2019 10:23 am
Am I correct in assuming that every variable in JavaScript holds merely a pointer to an independently existing object? E.g. if 'moves' is an array, and I would do
var savedMoves = moves;
moves = [];
... // assign something to the elements move[n]
moves = savedMoves;
that I would have my original array of moves back unmodied, and that the operation savedMoves = moves is just a simple assignment of a pointer, rather than actual copying of the entire array?
var savedMoves = moves;
moves = [];
... // assign something to the elements move[n]
moves = savedMoves;
that I would have my original array of moves back unmodied, and that the operation savedMoves = moves is just a simple assignment of a pointer, rather than actual copying of the entire array?