What does this [0] do at end of splice function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What does this [0] do at end of splice function

Const arr = fruits.splice(fromindex,1)[0] , fruits is a array with 5 objects

2nd Apr 2020, 3:55 AM
Nikhil Tale
Nikhil Tale - avatar
4 Answers
+ 2
It's deleting fruits[fromindex] and storing it in arr constant.
2nd Apr 2020, 4:14 AM
Kevin ★
+ 1
[0] is used to get the first element of the array.
2nd Apr 2020, 4:02 AM
Kevin ★
0
So what it is doing with splice suppose array is [nikhil,joy,jay,ram,alice] so what will the above function do
2nd Apr 2020, 4:06 AM
Nikhil Tale
Nikhil Tale - avatar
0
Ohkk
2nd Apr 2020, 4:39 AM
Nikhil Tale
Nikhil Tale - avatar