I want remove one item from my array. For example i want remove "Apple" from array. The code like below :
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2,1);
When i run this code, the output is ["Apple"]. The output should be ["Banana", "Orange", "Mango"]. Please help me to find what wrong with my code?
["Banana", "Orange", "Mango"], check the value offruits. You might be looking at the return value ofsplice.["Apple"]because i try toconsole.log(fruits.splice(2,1))and like all you say it return value of splice not the value of array. After that i tryconsole('fruits')and it's return["Banana", "Orange", "Mango"]. Thanks for the solution @gurvinder372 @js_noob