Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

store data to the browser’s localStorage

export const setToLS = (key, value) => {
  window.localStorage.setItem(key, JSON.stringify(value));
}

export const getFromLS = key => {
  const value = window.localStorage.getItem(key);

  if (value) {
    return JSON.parse(value);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: create element javascript save to local storage 
Javascript :: check ObjectId is valid in mongoose 
Javascript :: javascript replace space by underscore 
Javascript :: js replace single quote with doubel quote 
Javascript :: how to disable ctrl key using javascript 
Javascript :: set time out js 
Javascript :: jquery extract number from string 
Javascript :: boxshadow in react native 
Javascript :: document ready function 
Javascript :: jquery initialize 
Javascript :: how to get the value of dropdown in jquery 
Javascript :: javascript check if object is empty 
Javascript :: get the first day and last day of current mongth javascript 
Javascript :: reset a select option jquery 
Javascript :: javascript backticks and if statements 
Javascript :: check if path is folder js 
Javascript :: npx for windows 
Javascript :: giving height full in next image 
Javascript :: js number remove last 2 characters 
Javascript :: jquery loop through each child element 
Javascript :: fibonacci sequence in javascript using for loop 
Javascript :: jquery set checkbox checked unchecked 
Javascript :: angular pipe first letter uppercase 
Javascript :: gdscript yield timer 
Javascript :: Hide a div on clicking outside it with jquery 
Javascript :: logout in react js 
Javascript :: jquery set value by name 
Javascript :: jspdf text align center 
Javascript :: express server how to get request ip 
Javascript :: jquery smooth scrool 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =