Answer the question
In order to leave comments, you need to log in
How to get the index of an array inside an array in Vue.js?
How to get the INDEX_ARray inside an array without the this keyword , because in Vue.js does it point to the parent?
Thank you!
var my_array = [{
data: 123,
operation: my_array[ИНДЕКС_МАССИВА].data * 5
}, {
data: 845,
operation: my_array[ИНДЕКС_МАССИВА].data * 2
}, {
data: 'dsdsd',
operation: my_array[ИНДЕКС_МАССИВА] + 'qwqwqw'
}]
Answer the question
In order to leave comments, you need to log in
When you start sorting through the array, then you will get the indices.
https://learn.javascript.ru/array-iteration
You have a task of knowledge of bare JavaScript.
var my_array =
[
{
data: 123
},
{
data: 845
},
{
data: 'dsdsd'
}
];
my_array.forEach(function(item, i, arr)
{
switch(i)
{
case 0:
item.operation = item.data * 5;
break;
case 1:
item.operation = item.data * 2;
break;
default:
item.operation = item.data + 'qwqwqw';
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question