F
F
fandorin_official2018-02-12 15:54:46
JavaScript
fandorin_official, 2018-02-12 15:54:46

How to write an element to an array?

All good.
Tell me please. There is this array:

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

I want to remove the first element of the input array, write a new value at the end. For example, to make an array look like:
var mass= [
        {input: [ 1, 2, 3, 4, 5, 6, 7, 8], output: [1]}, //1
    ];

I tried commands like
mass.input.shift();
mass.input.push(8);
but it seems to work differently. How?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Zharov, 2018-02-12
@fandorin_official

mass[0].input.shift();
mass[0].input.push(8);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question