I have:
- patharray, that is containing pairs of- x,ycoordinates
- configdictionary contains with the only current path (of course config actually containing some parameters, so please do not try to remove it)
- initialPath, that should constantly contain initial- pathvalues without any changes
I want my current (config) path to change its x values relatively from its initial values:
// create config which should store some params
var config = {};
// initial array
var path = [[0,0], [10,10], [20,20]];
// initialPath is an array that I want to stay constant
// because new position of the path will be calculated by initial path 
// (not current that is in config) multiply on some koefficient
var initialPath = [...path]; // deep copy path
config.path = [...path]      // deep copy path
console.log("initialPath before", initialPath );
for (var i = 0; i < config.path.length; i++) {
    for (var j = 0; j < config.path[i].length; j++) {
        // I want initial path do NOT change here, but it does
        config.path[i][0] = initialPath[i][0] * 2;     
    }
}
console.log("initialPath after", initialPath );
So every time I multiply x coords they should change relatively from initialPath, not current.
Output I have:
// initialPath before:
// Array(3)
// 0: (2) [0, 0]
// 1: (2) [40, 10]
// 2: (2) [80, 20]
// initialPath after:
// Array(3)
// 0: (2) [0, 0]
// 1: (2) [40, 10]
// 2: (2) [80, 20]
As we see initialPath is changed its values
Output I want:
// initialPath before:
// Array(3)
// 0: (2) [0, 0]
// 1: (2) [10, 10]
// 2: (2) [20, 20]
// initialPath after:
// Array(3)
// 0: (2) [0, 0]
// 1: (2) [10, 10]
// 2: (2) [20, 20]
PS Probably title is confusing for that question, so please change it if you know exactly how this problem is named
 
     
     
    