Why this happend?

Hi! this is a short question, why when I write
console.log(groceryList.unshift(‘popcorn’))
the output is
8

and when I write
groceryList.unshift(‘popcorn’)

console.log(groceryList)
the output is
‘popcorn’,
‘orange juice’,
‘bananas’,
‘coffee beans’,
‘brown rice’,
‘pasta’,
‘coconut oil’,
‘plantains’

Is not should be the same?

Looking at the documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift

We can see that unshift returns the new length of the array. So logging the returned value of unshift is different from logging the array