Skip to content

Instantly share code, notes, and snippets.

@qkreltms
Last active September 10, 2018 09:03
Show Gist options
  • Select an option

  • Save qkreltms/2be842339b63f5b4c952626105b89d94 to your computer and use it in GitHub Desktop.

Select an option

Save qkreltms/2be842339b63f5b4c952626105b89d94 to your computer and use it in GitHub Desktop.
Simple javascript local storage usage example with JSON
<html>
</html>
<script>
let a = {
test1: 1,
test2: 2
}
localStorage.setItem('test', JSON.stringify(a))
let temp = JSON.parse(localStorage.getItem('test'))
var text = document.createTextNode(temp.test1)
document.body.appendChild(text)
</script>
@qkreltms
Copy link
Author

qkreltms commented Sep 2, 2018

.stringify(a) 대신 .json(a) 써도 됨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment