我有一个数组存储(解析为json)在localstorage中。 我把它带回到一个对象中,从中删除了一些项目,我需要用本地存储中的新值更新密钥。从本地存储中删除数组项目
var counter = [0,1,2];
var count = counter[0];
var questions = localStorage.getItem('questions');///questions had been stored in local storage with another function
console.log(questions);
questions = $.parseJSON(questions);
if (questions != 0){
$('.question').html(questions[count]['question']);
var options = (questions[count]['options']);
options.forEach(function (item) {
$('.options').html(item);
});
var index = counter.indexOf(1);
questions = questions.splice(index, 1);
console.log(questions);
localStorage.removeItem('questions);
counter = counter.splice(index, 0);
现在,当我删除从本地存储问题的关键,整个问题阵列被删除,但是,我只需要删除已传递的特定问题阵列。