Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sotre json on chrome storage

var local = (function(){

    var setData = function(key,obj){
        var values = JSON.stringify(obj);
        localStorage.setItem(key,values);
    }

    var getData = function(key){
        if(localStorage.getItem(key) != null){
        return JSON.parse(localStorage.getItem(key));
        }else{
            return false;
        }
    }

    var updateDate = function(key,newData){
        if(localStorage.getItem(key) != null){
            var oldData = JSON.parse(localStorage.getItem(key));
            for(keyObj in newData){
                oldData[keyObj] = newData[keyObj];
            }
            var values = JSON.stringify(oldData);
            localStorage.setItem(key,values);
        }else{
            return false;
        }
    }

    return {set:setData,get:getData,update:updateDate}
})();
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert node.js to ES6 
Javascript :: javascript allow only numeric characters 
Javascript :: select2 clear fields 
Javascript :: call javascript function use array 
Javascript :: add property to object conditionally 
Javascript :: js document.addEventListner 
Javascript :: how to find length of array in javascript without using length method 
Javascript :: axios set body 
Javascript :: check if string contains substring javascript 
Javascript :: webpack bundle analyzer 
Javascript :: discord js check if person banned 
Javascript :: javascript on keypu 
Javascript :: momentjs range 
Javascript :: js conditional object 
Javascript :: chrome add a bookmark that appends to current url 
Javascript :: jquery table row count 
Javascript :: add css on click javascript 
Javascript :: jquery noconflict 
Javascript :: add event listener in react useeffect 
Javascript :: javascript getelementbyid 
Javascript :: swal change confirm button class 
Javascript :: xmlhttprequest error handling 
Javascript :: typing animation in js 
Javascript :: how to disable copy paste in input js 
Javascript :: javascript js isNumber 
Javascript :: javascript Using Math.min() on an Array 
Javascript :: check checkbox based on value using jquery 
Javascript :: jquery on modal close event 
Javascript :: authfunctions 
Javascript :: javascript colab connect 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =