I know that I can test for a JavaScript variable and then define it if it is undefined
, but is there not some way of saying
var setVariable = localStorage.getItem('value') || 0;
seems like a much clearer way, and I’m pretty sure I’ve seen this in other languages.