On console i am getting the values of the array which are added afterwards using the unshift command

JS CODE =>

let arr = [1,2,3,‘dasdas’];

arr.shift();

console.log(arr);

console.log(arr[0]);

arr.unshift(“sdsa”,1);

console.log(arr);


OUTPUT =>

sdsa,1,2,3,dasdas

2

sdsa,1,2,3,dasdas


Why am i getting this output shouldn’t the ouput be this =>

2,3,dasdas // < = CHANGED

2

sdsa,1,2,3,dasdas

On using index i am getting the right anwer .
Why is this happening ?

Please share a screenshot of code and corresponding output with it. The expected output should be the actual output as per the code.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.