[Web] 無順序的 Array Object 刪除(delete object in array with No Sequence ID )
Published: (Updated: )
by .var bookData = [{
"BookId":1,
"BookCategory":"資料庫",
"BookName":"DB2:Maximizing Performance of Online Production Systems",
"BookAuthor":"W.H.Inmon",
"BookBoughtDate":"1990-06-18",
"BookPublisher":"創創公司"
},{
"BookId":3,
"BookCategory":"資料庫",
"BookName":"精通SQL Server 7.0資料庫系統",
"BookAuthor":"方盈",
"BookBoughtDate":"1990-06-18",
"BookPublisher":"零壹"
},
{
"BookId":2,
"BookCategory":"資料庫",
"BookName":"DB2 Answers! Certified Tech Support",
"BookAuthor":"Richard Yevich",
"BookBoughtDate":"1990-06-18",
"BookPublisher":"WESLEY"
}]
var bookDataFromLocalStorage = bookData;
var removeIndex = bookDataFromLocalStorage.map(function(item){
return item.BookId
}).indexOf(data.BookId);
bookDataFromLocalStorage.splice(removeIndex , 1);