Storage.length
Storage
인터페이스의 length
읽기 전용 속성은 Storage
객체에 저장된 데이터 항목의 수를 반환합니다.
구문
length = storage.length;
반환 값
Storage
객체에 저장된 항목의 수.
예제
다음의 함수는 현재 도메인의 로컬 저장소에 세 개의 항목을 추가한 후 저장소 항목의 수를 반환합니다.
function populateStorage() {
localStorage.setItem('bgcolor', 'yellow');
localStorage.setItem('font', 'Helvetica');
localStorage.setItem('image', 'cats.png');
return localStorage.length; // Should return 3
}
참고: 실제 사용 예제를 보시려면 저희의 Web Storage Demo를 방문하세요.
명세
Specification |
---|
HTML Standard # dom-storage-length-dev |
브라우저 호환성
BCD tables only load in the browser