please elaborate it with an example. what is the function of splice? where do we use it?
What is the function of splice?
The splice() method adds/removes items to/from an array, and returns the removed item(s).
For eg:
var fruits = [“Banana”, “Orange”, “Apple”, “Mango”];
fruits.splice(0, 1);
console.log(fruits);
It will return [“Orange”,“Apple”,“Mango”]
This means splice has removed 1 item from array position 0 i.e. Banana
To see add example check this: https://www.w3schools.com/jsref/jsref_splice.asp
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.