Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM Storage key() Method

Improve Article
Save Article
  • Last Updated : 04 Aug, 2022
Improve Article
Save Article

The DOM Storage key() Method is related to the Storage object and is used to return the name of the key with the specified index. Storage object can be either a localStorage or sessionStorage Object. 


  • Local storage:
  • Session storage:

Parameters: It accepts a parameter i.e. index to get the name of the key with that particular given index.

Return Values: It returns the name of the key in the form of the string.

Below is the HTML code to show the working of HTML DOM Storage key() Object:


<!DOCTYPE html>
        HTML DOM Storage key() Method
    <!-- Script to get the name of the key -->
        function myGeeks() {
            var key = localStorage.key(0);
            "geeks").innerHTML = key;
    <h2>DOM Storage key() Method</h2>
    <button onclick="myGeeks()">
    <p id="geeks"></p>


  • Before Click: 

  • After Click: 

Supported Browsers: The browser supported by DOM Storage key() Method are listed below:

  • Google Chrome 4
  • Edge 12 
  • Internet Explorer 8
  • Firefox 3.5
  • Opera 10.5
  • Safari 4
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!