Is this "correct" sessionstorage?

In my app, I have a splash screen showing on launch according to code on index.html. However, to prevent it from launching every time the Back button takes one to the index.html page, I set a number in sessionstorage so that if the number is there, it won’t launch again as long as it’s still in memory. This works fine.

However, I am having it check a value in sessionstorage before a value has been written, so I’m not sure this is “correct” syntax, even though it works. Is there a correct way to do this?

function onBodyLoad() {
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
// Check session storage to see if splash screen already appeared
function countLaunchImage() {
/* If the value is 0 then it's already displayed. If > 0, then t hasn't yet shown and should display. */
 var name = sessionStorage.getItem("count");
 if (name > 0) { showLaunchImage(); }
function showLaunchImage() {
// Show splash screen;
// Set value to 0 after it appears
sessionStorage.setItem("count", "0");
// countLaunchImage() should now see a 0 and not launch next time.
setTimeout(function() {
}, 1000);

It is correct. getItem will return null if the key doesn’t exist, and null > 0 evaluates to false, so it does what you want (or does it?).

Here’s the spec for getItem:

Thank you! I appreciate the answer.

Interesting that this was moved to JS. I thought it was a spec of HTML5:

Session storage has a JavaScript API, hence the JS forum.
Thank you for taking the time to think about where to post though. It is appreciated.