angular local storage

JavaScript
localStorage.setItem('dataSource', this.dataSource.length); // setting
console.log(localStorage.getItem('dataSource')); // gettinglocalStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the keyfunction createItem() {
	localStorage.setItem('nameOfItem', 'value'); 
} 
createItem() // Creates a item named 'nameOfItem' and stores a value of 'value'

function getValue() {
	return localStorage.getItem('nameOfItem');  
} // Gets the value of 'nameOfItem' and returns it
console.log(getValue()); //'value';
Source

Also in JavaScript: