how to get local storage value in javascript

JavaScript
  var x = localStorage.getItem("key"); 
Source

Also in JavaScript: