F
F
fandorin_official2018-06-30 15:02:58
JavaScript
fandorin_official, 2018-06-30 15:02:58

How to overwrite data in an array?

All good. There is an array.

var trainingData = [
        { input: [0], output: [0] },
        { input: [1], output: [1] },
        { input: [2], output: [2] },
        { input: [3], output: [3] },
        { input: [4], output: [4] },
        { input: [5], output: [5] },
        { input: [6], output: [6] },
    ];

It is required, as new data arrives, to rewrite the data in the array. That is, at the next iteration, line 2 becomes the first, the third the second, and so on.
That is, at the next iteration, the array should be like this:
var trainingData = [
        { input: [1], output: [1] },
        { input: [2], output: [2] },
        { input: [3], output: [3] },
        { input: [4], output: [4] },
        { input: [5], output: [5] },
        { input: [6], output: [6] },
        { input: [новые данные], output: [новые данные] },
    ];

Tried to implement it somehow like this:
trainingData[0].input.shift(); - 
        trainingData[0].output.shift();
        trainingData[trainingData.length-1].input.push(новые даные);
        trainingData[trainingData.length-1].output.push(новые даные);

But apparently I'm doing something wrong :(
How can I implement it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question