javascript - weird array behavior with .push -
I am working on a scheduling script which collects scheduled data from a multi-dimensional array and only push the value from the original array. Gives the present time to correspond to a second multi-dimensional array that only includes people currently working.
Here is a simple example of how data is collected:
[["John Smith", 07001700], ["Peter Smith", 0900 , 1600]]
Only in my data, the initial time is placed in index 7 and the end time is in index 8 internal array (not sure that I am using the correct terminology here I am).
If my statement is evaluating two values from the real timetable (start time and end time) which is located in an array of working, given that the present time between those values , And if it uses pushing method to copy the corresponding array (worker's name, start / end time, etc.) into a new array called functional, now.
In addition to the building, the initial array is working. From the schedule that pulls you from any other site, I do not make any modification on this array. Every other function I am working on, after that is done on the job. Now after that initial statement if the statement which works by dragging data from the work is working today. Now.
The problem I have is the row below and below, it also modifies the basic functioning. The array is compressing some other features which I am trying to apply. I was under the impression that by pushing the values into a new array, they are not linked to the old array, but I think it can be wrong.
Here is my code for the I statement:
var = working [=] []; To convert time strings to (i = 0; i & lt; workingToday.length; i ++) {// var startTime = parseInt (working [i] [7]); Var endime = parseint (working [i] [8]); // Compare the start and end time with current time and if you work for anew (initial time & lt; parseInt (moment). Format ('hm')) Hhmm ')) & lt; EndTime) {workNow.push (working today [i]); }; };
As an example of the problem I am facing, I say that I have pulled this data to work (today I have just like an employee ID for Index 1 And added value:
[["John Smith", 1234,0700, 1700], ["Peter Smith", 4567,0 9 00,1600], ["June Smith" 89011200, 2200]]
and the present time is 1100. Working should now be produced:
[["John Smith", 1234 , 07001700], ["Peter Smith", 4567,0 9 00,1600]]
Since June worked Then, afterwards, I use the splice method to remove the employee ID to get it:
[["John Smith", 0700, 1700], ["Peter Smith", 09001600]]
The problem is facing that even though I did this, the wedding ceremony at the time of working, also revised the values from the original work Is done so that the employee ID can be removed from there, so the work is going to end this way. ["John Smith", 07001700], ["Peter Smith", 09001600], ["June Smith", 890112002200]]
/ Code>
(where only June Smith is still in his employee ID array) although I do not execute these functions on the original function.
I hope that I'm making some meaning here. I want to be able to push values into a new array and modify the new array without affecting the basic values. If this is how the push function should work, then maybe I have made a mistake somewhere else - I can not really know where it will be, because I do not do anything else with actually working nowadays I do not know the array How is this being modified?