I am trying to reset an array through a function parameter.
Here is my code:
<script>
fruitArray = ["apple", "banana", "orange", "pineapple"]
function newFruit(myArray){
myArray=[];
}
newFruit(fruitArray)
alert(fruitArray[0])//Returns "apple"
</script>
I want to clear the array, but it is not working through the function. I am not sure about the line:
myArray=[];
Please help me learning this.
Thank you.