Variable saveConst

save: {
    add(props: object): void;
    remove(key: string): void;
} = ...

Type declaration

  • add:function
    • Add new keys to localStorage and set them to the given default values if they do not exist

      Parameters

      • props: object

        key and corresponding values

      Returns void

      add

      save

      // Initialize "score" and "lives" with default values
      me.save.add({ score : 0, lives : 3 });
      // get or set the value through me.save
      me.save.score = 1000;
  • remove:function
    • Remove a key from localStorage

      Parameters

      • key: string

        key to be removed

      Returns void

      remove

      save

      // Remove the "score" key from localStorage
      me.save.remove("score");