Reputation: 91959
$(function(){
$('body').on('click', '.queue', function(event) {
var video = $(this).closest('.video');
console.log(video);
var queue = localStorage.getItem('queue');
if (! queue ) {
queue = [];
}
queue.push(video);
localStorage.setItem('queue', queue);
console.log(localStorage.getItem('queue'));
bootstrap_alert.success('queued!');
});
});
when I try to test this, I get the error on console saying
TypeError: queue.push is not a function
queue.push(video);
What is that I am doing wrong here?
Upvotes: 0
Views: 2997
Reputation: 16961
var queue = localStorage.getItem('queue');
localStorage
doesn't store (or return) arrays. Therefore, queue
is not an array.
Upvotes: 6