I have array like this:
var myMovie = [];
And object like this:
var first = {id:"tt3783958", title:"La La Land", year:"2016", type:"Comedy, Drama, Music"}
I added object into local storage array via OnClick() on button.
$(document).ready(function() {
$(".btn.btn-outline-success").click(function () {
myMovie.push(first);
localStorage.setItem('myMovie', JSON.stringify(myMovie));
var output = JSON.parse(localStorage.getItem('myMovie'));
After adding object into local storage, local storage looks like this:
[{id:"tt3783958", title:"La La Land", year:"2016", type:"Comedy, Drama, Music"}]
My question here is, how could I remove whole object via variable name? I want to remove object first from myMovie. Index position of object may be different each time.
[{id:"tt3783958", title:"La La Land", year:"2016", type:"Comedy, Drama, Music"}, [{id:"tt9574821", title:"Ghost Protocol", year:"2012", type:"Action, Adventure"}]
firstto index?? You mean if the variable name issecond, you want to remove item at second index??{id:"tt3783958", title:"La La Land", year:"2016", type:"Comedy, Drama, Music"} from arraymyMovieeven if is on second index or third in array.