Skip to content

Instantly share code, notes, and snippets.

@channprj
Last active March 8, 2017 04:08
Show Gist options
  • Save channprj/7d680c6db8db18796978f9067e29380e to your computer and use it in GitHub Desktop.
Save channprj/7d680c6db8db18796978f9067e29380e to your computer and use it in GitHub Desktop.
Simple and naive implementation of array without duplicated items; Python set-like data structure written in JS. #help #wanted
var jsSet = { item: 0 }; // use Object key as set item
item = 'setItem'
if (!(item in jsSet)) { // if item not in jsSet
jsSet[item] = 1; // save item with meaningless value
}
sessionStorage.setItem('jsSet', JSON.stringify(Object.keys(usages))) // save into sessionStorage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment