Question 16
Consider the below Vue component.
<template> <div> <button @click="setDarkMode">Dark Mode</button> <button @click="setLightMode">Light Mode</button> </div></template>
<script>export default { data() { return { theme: localStorage.getItem('theme') || 'light' }; }, methods: { setDarkMode() { this.theme = 'dark'; localStorage.setItem('theme', 'dark'); }, setLightMode() { this.theme = 'light'; localStorage.setItem('theme', 'light'); } }};</script>Which of the following statement(s) is/are correct about the behavior of the above component?
The theme will persist across page reloads because it is stored in localStorage.
If the user opens a new tab, the theme will reset to 'light' in that new tab.
The theme will reset to 'light' every time the page is refreshed.
The theme will be shared across all open tabs, as localStorage is accessible across tabs of the same origin.