GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge remote-tracking branch 'origin/master' · MorrielAlexis/JavaScript-Lessons@afc7fe3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Data_Structures/Dictionaries
    • README.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Data_Structures/Dictionaries/README.md‎

Copy file name to clipboard
+31-1Lines changed: 31 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
![](http://i.imgur.com/BgUMUGU.png)
2+
13
# Dictionaries
24

3-
A dictionary (also known as a map) is used to store key, value pairs.
5+
A dictionary (also known as a map) is used to store key, value pairs.
6+
7+
#Documentation
8+
9+
Here lies further explaination for the elements that were used in the examples.
10+
11+
##Dictionaries
12+
13+
**According to wikipedia:**
14+
"In computer science, a dictionary, (or an associative array) is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection."
15+
In Javascript dictionaries are very usefull because they give us a way to use a data stracture even in an statical content.
16+
17+
The dictionary's syntax looks like that
18+
*var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};* and every the "data" is a pair of a key, (some people call it name) and a value. this pair of key and value is called a property, so the dictionary is somehow an array which consists of properties.
19+
20+
In an dictionary we can do 4 basic actions, (please notice that as we did in our example we will call our dictionary with the variable name "dict", and that in the example we used the Dictionary through class so the syntax is different as how it is written in the documentation):
21+
- **Add or insert:** In order to add a pair we will have to use *push*
22+
*dict.push({
23+
key: "keyName",
24+
value: "the value"
25+
});*
26+
- **Reassign**: Sometimes we wish to change the value to some key in this case we use this syntax:
27+
*dict.keyname1 = "valuename1";*
28+
- **Remove or delete:** The best way to remove a property from a dictionary is to use the *delete* keyword:
29+
*delete dict["keyname"];*
30+
- **Lookup:** Thats is just an elaborate way to say that we wish to check, (to get actually), a value that is associated to a specific key. for example here we wish to prin the value of the key "keyname1" from the dictionary "dict":
31+
*console.log(dict['keyname1']);*
32+
33+
Sometimes instead of add or reassign there is a single set operation that adds a new (key,value) pair if one does not already exist, and otherwise reassigns it.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.