Skip to content

Instantly share code, notes, and snippets.

@Arieg419
Last active December 20, 2016 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arieg419/f4ed3ec394741bd21c1bc8db05d37fb0 to your computer and use it in GitHub Desktop.
Save Arieg419/f4ed3ec394741bd21c1bc8db05d37fb0 to your computer and use it in GitHub Desktop.
var person = new Map();
person.set("Formal Name", "Kanye West");
person.set("Alias", "Yeezy");
person.set("Goal", "GOAT"); // don't stop reading here!
console.log(person.has("Formal Name")) // true
console.log(person.size); // 3
person.delete("Goal");
console.log(person.has("Goal")); // false
console.log(person.size); // 2
var result = person.get("Alias");
console.log(result); // "Yeezy"
console.log(person.keys()); // "Formal Name", "Alias"
console.log(person.values()); // "Kanye West", "Yeezy"
console.log(person.entries()); // ["Formal Name", "Kanye West"], ["Alias", "Yeezy"]
person.clear();
console.log(person.size); // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment