tôi có một tình huống như thế này,làm thế nào để thúc đẩy một phần tử ở chỉ số 0 của một mảng
tôi có 2 array1
như array1 = ["fruit","vegetables"];
và
array2 = [["apple","banana"],["tomato"]]; // index 0:represent fruit i,e (["apple","banana"]), index 1: vegetables i,e (["tomato"])
câu hỏi của tôi: làm thế nào tôi có thể push item
từ array1
để làm cho array2
của tôi trông giống như thế này
[["fruit","apple","banana"],["vegetables","tomato"]];
với điều đó tôi có thể xác định index:0
như category
.
MYdata structure
là những 2 array
array1 = ["fruit","vegetables"];
VÀ array2 = [["apple","banana"],["tomato"]];
nếu tôi có thể nhận được key
value
cặp array
rằng sẽ tốt cho tôi.
dữ liệu mẫu của tôi:
array1 = ["fruit","vegetables"];
array2 = [["apple","banana"],["tomato"]]; //expected output :[["fruit","apple","banana"],["vegetables","tomato"]];
@balan lời giải thích tốt từng bước cảm ơn rất nhiều – EaB