Good day. Array:
var cap = [ ['a', 'b', 'c', 1], ['a', 'q', 'c', 0] ]; It is necessary to add an element equal to the last current to the end of the array, while changing the current value of 0 to 1, i.e. get the view:
cap = [ ['a', 'b', 'c', 1], ['a', 'q', 'c', 1], ['a', 'q', 'c', 0] ]; I do this:
cap.push(cap[cap.length-1]); cap[cap.length-1][3]= 1; but I get all the units at the end. Correct, please. Thank.
PS
The first line changed to:
cap[cap.length] = cap[cap.length-1]; same result instead
cap = [ ['a', 'b', 'c', 1], ['a', 'q', 'c', 1], ['a', 'q', 'c', 0] ]; I get:
cap = [ ['a', 'b', 'c', 1], ['a', 'q', 'c', 1], ['a', 'q', 'c', 1] ]; UPD_2 I think the problem is that I insert the element not as an array, I did this:
cap[cap.length] = '['+cap[cap.length-1]+']'; also some kind of curvature, but with numbers 0 and 1 here is already ok ...