how to check if an object exists in javascript -


i want check if window.sessionstorage object exists. way it:

if (window.sessionstorage) 

in javascript?

if(sessionstorage.length == 0) {     //do } 

that validate whether sessionstorage empty or not. alternatively, can use this:

if(typeof(sessionstorage) == 'undefined')  {     //do } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

c++ - How to test/verify that zero-initialization takes place -

node.js - Webpack/TypeScript Raising Errors When node_modules is Excluded -