This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Storage.removeItem()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015년 7월⁩.

Storage 인터페이스의 removeItem() 메소드에 키 이름을 파라미터로 전달하면 스토리지에서 해당 키를 삭제합니다.

문법

js
storage.removeItem(keyName);

파라미터

keyName

삭제하고자 하는 키 이름(DOMString).

반환값

반환값 없음.

예제

아래의 함수는 로컬 스토리지에 3 개의 데이터 아이템을 생성한 후 그 중 하나를 삭제합니다.

js
function populateStorage() {
  localStorage.setItem("bgcolor", "red");
  localStorage.setItem("font", "Helvetica");
  localStorage.setItem("image", "myCat.png");

  localStorage.removeItem("image");
}

참고 : 실 사용 예제는 Web Storage Demo를 참고하시기 바랍니다.

명세서

Specification
HTML
# dom-storage-removeitem-dev

브라우저 호환성

같이 보기

Web Storage API 사용하기