+ 1

Related to JavaScript if and else statements

What is meant by following lines if(typeof(Storage)!=="undefined") else {"your browser does not support local storage"}

29th Mar 2020, 9:16 AM
Muhammad Awwab Khan
Muhammad Awwab Khan - avatar
1 Resposta
+ 3
For a javascript engine, this code means "syntax error"... But for an human it would be translated to this kind of correct code: if (typeof(Storage)!=="undefined") {} else { alert("your browser does not support local storage") } wich translated in human words means: "if object Storage exists do nothing, else display message to user", wich could be done less verbosely by: if (!Storage) { alert("your browser..." }
29th Mar 2020, 10:23 AM
visph
visph - avatar