var x = JSON.parse(localStorage.getItem('x')).length || 0;
Above code has an error. the || doesn't work in this case I wonder why. Actually I can do this with
var x = JSON.parse(localStorage.getItem('x');
if(x.length){
x = JSON.parse(localStorage.getItem('x').lengt6h
}
but that's 4 lines of code. Is there any way to do it in one line?