Question #46

Author: admin
tags: JavaScript  
let obj = { a: 1 };
localStorage.setItem('a', obj);
console.log(localStorage.getItem('a')); // ??
What will the console output be?
a
1
{ a: 1 }
[object Object]
Nothing. There is an error in the code.
localStorage accepts only strings as keys and values.
If a value that is not a string is passed to the setItem method, this value will be automatically converted to a string.
Rate the difficulty of the question:
easyhard