Are you ready?

1 questions to solve.

  1. This quiz goes to full-screen once you press the Start button, or any Next button after exiting the quiz window.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
Which of the following choices best describes the sessionStorage object?
sessionStorage is a property of the global window object. This goes with choice (A).
What will the following code log?
var o = { x: 10 };
localStorage.o = o;

console.log(typeof localStorage.o);
localStorage (and sessionStorage) converts each value into a string before storing it. In this case the object o is first converted into a string and then assigned to localStorage.o (in line 2). Thus, typeof localStorage.o will return "string", which goes with choice (A).
What will the following code log?
localStorage.num = 10;
localStorage.num += 5;

The first line stores the string "10" inside localStorage.num, which is then concatenated with the number 5 ("10" + 5) in line 2; resulting in "105". This goes with choice (C). To understand how strings concatenate with numbers, please refer to JavaScript Strings Basic Concepts.
localStorage stores data without any expiration time. True or false?
localStorage stores data permanently i.e it has no expiration time. This goes with choice (A). For more info please refer to Local Storage.
Assume that both the following HTML pages are opened in separate tabs, both having access to the same localStorage.
    localStorage.x = 10;
    window.onstorage = function(e) {

Will a localStorage change in page1.html cause a storage event to fire in page2.html?

localStorage fires a storage event in a window each time it's changed from another window. For a live example of this please refer to Local Storage.
Which of the following is the preferred way of removing a key x from localStorage?
Using methods defined by the Storage API are always preferred over the native object property-access syntax while working with localStorage or sessionStorage. This goes with choice (C).
Supposing that no key x exists on localStorage, what will localStorage.getItem("x") return?
If a non-existent key is passed to the method getItem(), it returns null. This goes with choice (B).
What does localStorage.clear() do?
clear() removes all data from a given storage object. For more info please refer to Local Storage.