Change key value in localStorage?
问题 I have a localStorage item named as "1" and containing "something". I want to change the name to "2" and leave the contents intact. How can I do that? I know that I can copy the entire contents to "2" and then delete "1" but is there any other direct method? 回答1: You can take a look at the official specification. The storage interface looks like this: interface Storage { readonly attribute unsigned long length; DOMString? key(unsigned long index); getter DOMString getItem(DOMString key);