"HTML5 로컬스토리지 딕셔너리 저장·인출"의 두 판 사이의 차이

잔글 (로봇: 자동으로 텍스트 교체 (-http://jmnote.com/html5/ +http://zetawiki.com/ex/html5/))
14번째 줄: 14번째 줄:


==예시==
==예시==
*예제: http://zetawiki.com/ex/html5/localStorage_dictionary.php
*예제: http://example.zetawiki.com/html5/localStorage_dictionary.php
<source lang='html5'>
<source lang='html5'>
<script>
<script>

2017년 4월 22일 (토) 22:31 판

HTML5 로컬스토리지 딕셔너리 저장·인출
HTML5 로컬스토리지 객체 저장

1 방법

var car1 = {type:"Fiat", model:500, color:"white"};
localStorage.car = JSON.stringify( car1 );
var car2 = JSON.parse( localStorage.car );

2 예시

<script>
var dict1 = {'foo':'hello', 'bar':'world'};
localStorage.my_dictionary = JSON.stringify(dict1);

var dict2 = JSON.parse(localStorage.my_dictionary);
console.log( dict2 );
// Object {foo: "hello", bar: "world"}
console.log( dict2['foo']);
// hello
</script>

3 같이 보기

4 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}