How to add object to localstorage in JavaScript

Storage
By Jad Joubran · 
Last updated Dec 19, 2017
const user = {
  id: 1,
  first_name: "John",
  last_name: "Doe"
};

localStorage.setItem("user", JSON.stringify(user));