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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -