diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
| commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
| tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/storage/key | |
| parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
| download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip | |
initial commit
Diffstat (limited to 'files/ko/web/api/storage/key')
| -rw-r--r-- | files/ko/web/api/storage/key/index.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/ko/web/api/storage/key/index.html b/files/ko/web/api/storage/key/index.html new file mode 100644 index 0000000000..7583b6e49f --- /dev/null +++ b/files/ko/web/api/storage/key/index.html @@ -0,0 +1,74 @@ +--- +title: Storage.key() +slug: Web/API/Storage/key +tags: + - 로컬 스토리지 + - 세션 스토리지 + - 웹 스토리지 +translation_of: Web/API/Storage/key +--- +<p>{{APIRef("Web Storage API")}}</p> + +<p>{{domxref("Storage")}} 인터페이스의 <code>key()</code> 메서드는 숫자 <code>n</code>이 전달되면 Storage의 <code>n</code>번째 key 이름을 반환합니다. key의 순서는 user-agent에 의해 정의되므로 이 순서에 의존성이 있어서는 안됩니다.</p> + +<h2 id="문법">문법</h2> + +<pre class="syntaxbox">var <em>aKeyName</em> = <em>storage</em>.key(<em>index</em>);</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><em>index</em></dt> + <dd>반환받으려하는 key의 번호를 나타내는 정수. 이 정수는 0부터 시작하는 인덱스입니다.</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>key 이름을 포함한 {{domxref("DOMString")}} 입니다.</p> + +<h2 id="예제">예제</h2> + +<p>다음 함수는 localStorage 의 key들을 반복합니다.</p> + +<pre class="brush: js">function forEachKey(callback) { + for (var i = 0; i < localStorage.length; i++) { + callback(localStorage.key(i)); + } +}</pre> + +<p>다음 함수는 localStorage 의 key들을 반복하고 각 key에 설정된 값들을 가져옵니다.</p> + +<pre class="brush: js">for(var i =0; i < localStorage.length; i++){ + console.log(localStorage.getItem(localStorage.key(i))); +}</pre> + +<div class="note"> +<p><strong>Note</strong>: 실제로 쓰이는 예제를 보려면 우리의 <a href="https://mdn.github.io/dom-examples/web-storage/">Web Storage Demo</a> 를 참조하세요.</p> +</div> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', 'webstorage.html#dom-storage-key', 'Storage.key')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + +<div class="hidden">이 페이지의 호환성 테이블은 구조화 된 데이터에서 생성됩니다. 데이터에 기여하고 싶다면 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 를 확인하고 Pull Request 를 보내주세요.</div> + +<p>{{Compat("api.Storage.key")}}</p> + +<h2 id="See_also">See also</h2> + +<p><a href="/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API">Using the Web Storage API</a></p> |
