![]() |
VOOZH | about |
The setItem() method is used to set the storage object item which is specified by the user. This storage object can be a localStorage object or sessionStorage object.
Syntax: For local storage:
localStorage.setItem(keyname, value)
For session storage:
sessionStorage.setItem(keyname, value)
Parameters: Two parameters are required :-
Return Value: A String, representing the inserted value.
Example:
Output:
Before:
After:
Supported Browsers: The browser supported by DOM setItem() Method are listed below: