javascript - sessionStorage setItem returns true or false -


i'm trying figure out setitem method sessionstorage returns. far get, following code returns undefined:

var set = sessionstorage.setitem('foo', 'bar'); console.log(set); 

i need know if item set or if failed. how can accomplish without knowing return?

take @ sessionstorage specification.

this line:

setter creator void setitem(domstring key, domstring value); 

tells setitem doesn't return anything. (void return value, there)


you can check if item set this:

if (sessionstorage.getitem('myvalue') == null){     // myvalue not set }else{     // myvalue set } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -