# Don't understand this topic:- Manipulate Arrays With unshift()

Don't understand this topic:- Manipulate Arrays With unshift()
0

#1

Tell us what’s happening:
I don’t understand how this unshift() works. I’m stuck here

``````
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.unshift(["paul",3]);
``````

User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36`.

#2
```unshift   adds something to the start of the area
push      adds something to the end of the area
shift     removes something from the start of the area
pop       removes something from the end of the area
```

does this help?

#3

The issue is that
var myArray = [ [“John”, 23], [“dog”, 3] ]; is a TWO dimensional array,
therefore, myArray[0] = [“John”, 23] and myArray[1] = [“dog”, 3]
each element of myArray is itself another array.
All these methods (functions), they do return values, in the case of shift & unshift they return the length of the new formed array. don’t get confused with:

var myArray = [ [“John”, 23], [“dog”, 3] ];
var test = myArray.unshift( ‘testvar’ );
console.log(test); // 3 (the new length of myArray)
console.log(myArray); // [ ‘testvar’, [“John”, 23], [“dog”, 3] ] (the myArray itself)

#4

not at all