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 :: jquery after 
Javascript :: angular findindex object based array 
Javascript :: javascript immediately invoked function expression 
Javascript :: map javascript index 
Javascript :: how to change color on js 
Javascript :: formula for scrollbar size 
Javascript :: javascript two character integer 
Javascript :: onclick change image src javascript 
Javascript :: jquery remove focus from all elements 
Javascript :: cdn jquery 
Javascript :: javascript random number generator 
Javascript :: watch with multiple variables vuejs 
Javascript :: count value a to b character javascript 
Javascript :: this.props.history.location.push 
Javascript :: react usestate functional update 
Javascript :: round js 
Javascript :: jquery check if input is empty 
Javascript :: binary search algorithm in javascript 
Javascript :: pyramid javascript 
Javascript :: renemane object key js 
Javascript :: event delegation in javascript 
Javascript :: jquery focus input end of text 
Javascript :: js capitalize word 
Javascript :: js check if div have another div 
Javascript :: difference between react native and react 
Javascript :: javascript destructure object and rename 
Javascript :: react router active link 
Javascript :: add tab to textarea 
Javascript :: how to replace strings with react components 
Javascript :: jquery click on data attribute 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =