Skip to content

Commit 68527fd

Browse files
committed
Map, set, promise, sync await added
1 parent b3f2cad commit 68527fd

File tree

1 file changed

+90
-93
lines changed

1 file changed

+90
-93
lines changed

readMe.md

Lines changed: 90 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@
55
# Table of Contents
66

77
1. [Introduction](#introduction)
8-
2. [Setup](#setup)
9-
3. [Variables](#variables)
10-
4. [Data Types](#data-types)
11-
5. [Operators](#operators)
12-
6. [Conditionals](#conditionals)
13-
7. [Arrays](#arrays)
14-
8. [Loops](#loops)
15-
9. [Functions](#functions)
16-
10. [Scope](#scope)
17-
11. [Hoisting](#Hoisting)
18-
12. [Object](#object)
19-
13. [Document Object Model](#document-object-model)
20-
14. [Class](#class)
21-
15. [Call Back and Higher Order Functions](#call-back-and-higher-order-functions)
22-
16. [Functional Programming](#functional-programming)
23-
17. [Destructuring](#destructuring)
24-
18. [Rest and Spread](#rest-and-spread)
25-
19. [Regular Expressions](#regular-expressions)
26-
20. [Local Storage](#local-storage)
27-
21. [Cookies](#cookies)
28-
22. [JavaScript Tests](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Tests):
29-
23. [JavaScript Interview Questions](#javascript-interview-questions)
8+
1. [Setup](#setup)
9+
1. [Variables](#variables)
10+
1. [Data Types](#data-types)
11+
1. [Operators](#operators)
12+
1. [Conditionals](#conditionals)
13+
1. [Arrays](#arrays)
14+
1. [Loops](#loops)
15+
1. [Functions](#functions)
16+
1. [Scope](#scope)
17+
1. [Hoisting](#Hoisting)
18+
1. [Object](#object)
19+
1. [Map and Set](#map-and-set)
20+
1. [Document Object Model](#document-object-model)
21+
1. [Class](#class)
22+
1. [Call Back and Higher Order Functions](#call-back-and-higher-order-functions)
23+
1. [Functional Programming](#functional-programming)
24+
1. [Destructuring](#destructuring)
25+
1. [Rest and Spread](#rest-and-spread)
26+
1. [Regular Expressions](#regular-expressions)
27+
1. [Local Storage](#local-storage)
28+
1. [Promises and Callback](#promises-and-callbacks)
29+
1. [Cookies](#cookies)
30+
1. [JavaScript Tests](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Tests):
31+
1. [JavaScript Interview Questions](#javascript-interview-questions)
3032

3133

3234
# Introduction
@@ -111,8 +113,6 @@ The external script link can be on the header or body but it is preferred to put
111113
<script src="introduction.js"></script>
112114
</head>
113115
<body>
114-
//it could be in the header or in the body
115-
<script src="introduction.js"></script>
116116
</body>
117117
</html
118118
```
@@ -835,10 +835,10 @@ console.log(eightEmptyValues); // [empty x 8]
835835
const arr = Array(); // creates an an empty array
836836
console.log(arr);
837837
const eightXvalues = Array(8).fill('X'); // it creates eight element values
838-
console.log(eightXvalue); // ['X', 'X','X','X','X','X','X','X']
838+
console.log(eightXvalues); // ['X', 'X','X','X','X','X','X','X']
839839
```
840840

841-
concat:To concatinate two arrays.
841+
concat:To concatenate two arrays.
842842

843843
```js
844844
const firstList = [1, 2, 3];
@@ -899,21 +899,21 @@ toString:Converts array to string
899899
```js
900900
const numbers = [1, 2, 3, 4, 5];
901901
console.log(numbers.toString()); // 1,2,3,4,5
902-
const names = ['Asabeneh', 'Matias', 'Elias', 'Brook'];
903-
console.log(names.toString()); // Asabeneh,Matias,Elias,Brook
902+
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'];
903+
console.log(names.toString()); // Asabeneh,Mathias,Elias,Brook
904904
```
905905

906906
join:To join the elements of the array, the argument passed in the join method will be joined in the array and return as a string.
907907

908908
```js
909909
const numbers = [1, 2, 3, 4, 5];
910910
console.log(numbers.join()); // 1,2,3,4,5
911-
const names = ['Asabeneh', 'Matias', 'Elias', 'Brook'];
912-
console.log(names.join()); // Asabeneh,Matias,Elias,Brook
913-
console.log(names.join('')); //AsabenehMatiasEliasBrook
914-
console.log(names.join(' ')); //Asabeneh Matias Elias Brook
915-
console.log(names.join(', ')); //Asabeneh, Matias, Elias, Brook
916-
console.log(names.join(' # ')); //Asabeneh # Matias # Elias # Brook
911+
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'];
912+
console.log(names.join()); // Asabeneh,Mathias,Elias,Brook
913+
console.log(names.join('')); //AsabenehMathiasEliasBrook
914+
console.log(names.join(' ')); //Asabeneh Mathias Elias Brook
915+
console.log(names.join(', ')); //Asabeneh, Mathias, Elias, Brook
916+
console.log(names.join(' # ')); //Asabeneh # Mathias # Elias # Brook
917917
```
918918

919919
Slice: To cut out a multiple items in range. It takes two parameters:starting and ending position. It doesn't include the ending position
@@ -2197,61 +2197,6 @@ console.log(result);
21972197
#### Exercises:Regular Expressions
21982198
- Calculate the total annual income of the person from the following text. ‘He earns 4000 euro from salary per month, 10000 euro annual bonus, 5500 euro online courses per month.’
21992199
2200-
## localStorage
2201-
2202-
Local storage is the para of the web storage API which is used to store data on the browser with no expiration data. The data will be available on the browser even after the browser is closed. There are five methods to work on local storage:
2203-
_setItem(), getItem(), removeItem(), clear(), key()_
2204-
2205-
##### Setting item to the localStorage
2206-
When we set data to be stored in a localStorage, it will be stored as a string. If we are storing an array or an object, we should stringify it first to keep the format unless otherwise we lose the array structure or the object structure of the original data
2207-
```js
2208-
localStorage.setItem('name', 'Asabeneh');
2209-
console.log(localStorage) //Storage {name: 'Asabeneh', length: 1}
2210-
localStorage.setItem('age', 200);
2211-
console.log(localStorage) //Storage {age: '200', name: 'Asabeneh', length: 2}
2212-
const skills = ['HTML', 'CSS', 'JS', 'React'];
2213-
//Skills array has to be stringified first to keep the format.
2214-
const skillsJSON = JSON.stringify(skills,undefined, 4)
2215-
localStorage.setItem('skills', skillsJSON);
2216-
console.log(localStorage) //Storage {age: '200', name: 'Asabeneh', skills: 'HTML,CSS,JS,React', length: 3}
2217-
```
2218-
If we are storing an array, an object or object array, we should stringify the object first. See the example below.
2219-
```js
2220-
2221-
let skills = [
2222-
{ tech: 'HTML', level: 10 },
2223-
{ tech: 'CSS', level: 9 },
2224-
{ tech: 'JS', level: 8 },
2225-
{ tech: 'React', level: 9 },
2226-
{ tech: 'Redux', level: 10 },
2227-
{ tech: 'Node', level: 8 },
2228-
{ tech: 'MongoDB', level: 8 }
2229-
];
2230-
2231-
let skillJSON = JSON.stringify(skills);
2232-
localStorage.setItem('skills', skillJSON);
2233-
```
2234-
##### Getting item from localStorage
2235-
```js
2236-
let name = localStorage.getItem('name');
2237-
let age = localStorage.getItem('age');
2238-
let skills = localStorage.getItem('skills');
2239-
console.log(name, age, skills) // 'Asabeneh', '200', '['HTML','CSS','JS','React']'
2240-
2241-
2242-
let skillsObj = JSON.parse(localStorage.getItem('skills'), undefined, 4);
2243-
console.log(skillsObj);
2244-
2245-
```
2246-
##### Clearing the localStorage
2247-
The clear method, will clear everything stored in the local storage
2248-
```js
2249-
localStorage.clear();
2250-
```
2251-
2252-
## Exercises:Local Storage
2253-
2254-
## Cookies
22552200
## Promises and Callbacks
22562201
From the following code blocks you will notice, the difference between callback and promises:
22572202
@@ -2355,12 +2300,64 @@ console.log(square(10))
23552300
fetchData()
23562301
```
23572302
2303+
## localStorage
23582304
2305+
Local storage is the para of the web storage API which is used to store data on the browser with no expiration data. The data will be available on the browser even after the browser is closed. There are five methods to work on local storage:
2306+
_setItem(), getItem(), removeItem(), clear(), key()_
2307+
2308+
##### Setting item to the localStorage
2309+
When we set data to be stored in a localStorage, it will be stored as a string. If we are storing an array or an object, we should stringify it first to keep the format unless otherwise we lose the array structure or the object structure of the original data
2310+
```js
2311+
localStorage.setItem('name', 'Asabeneh');
2312+
console.log(localStorage) //Storage {name: 'Asabeneh', length: 1}
2313+
localStorage.setItem('age', 200);
2314+
console.log(localStorage) //Storage {age: '200', name: 'Asabeneh', length: 2}
2315+
const skills = ['HTML', 'CSS', 'JS', 'React'];
2316+
//Skills array has to be stringified first to keep the format.
2317+
const skillsJSON = JSON.stringify(skills,undefined, 4)
2318+
localStorage.setItem('skills', skillsJSON);
2319+
console.log(localStorage) //Storage {age: '200', name: 'Asabeneh', skills: 'HTML,CSS,JS,React', length: 3}
2320+
```
2321+
If we are storing an array, an object or object array, we should stringify the object first. See the example below.
2322+
```js
2323+
2324+
let skills = [
2325+
{ tech: 'HTML', level: 10 },
2326+
{ tech: 'CSS', level: 9 },
2327+
{ tech: 'JS', level: 8 },
2328+
{ tech: 'React', level: 9 },
2329+
{ tech: 'Redux', level: 10 },
2330+
{ tech: 'Node', level: 8 },
2331+
{ tech: 'MongoDB', level: 8 }
2332+
];
2333+
2334+
let skillJSON = JSON.stringify(skills);
2335+
localStorage.setItem('skills', skillJSON);
2336+
```
2337+
##### Getting item from localStorage
2338+
```js
2339+
let name = localStorage.getItem('name');
2340+
let age = localStorage.getItem('age');
2341+
let skills = localStorage.getItem('skills');
2342+
console.log(name, age, skills) // 'Asabeneh', '200', '['HTML','CSS','JS','React']'
2343+
2344+
2345+
let skillsObj = JSON.parse(localStorage.getItem('skills'), undefined, 4);
2346+
console.log(skillsObj);
2347+
2348+
```
2349+
##### Clearing the localStorage
2350+
The clear method, will clear everything stored in the local storage
2351+
```js
2352+
localStorage.clear();
2353+
```
2354+
2355+
## Exercises:Local Storage
2356+
2357+
## Cookies
23592358
## [JavaScript Tests](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Tests)
23602359
## JavaScript Interview Questions
2361-
23622360
#### Exercises:Cookies
2363-
23642361
### [JavaScipt Tests](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Test-1)
23652362
##### [JavaScript Test 1](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Test-1)
23662363
##### [JavaScript Test 2](https://github.com/Asabeneh/JavaScript-for-Everyone/wiki/JavaScript-Test-2)
@@ -2485,14 +2482,14 @@ ___
24852482
- [Creating a pattern with flags: global flag (g), case insensitive flag(i)](#creating-a-pattern-with-flags-global-flag-g-case-insensitive-flagi)
24862483
- [RegExp Object Methods](#regexp-object-methods)
24872484
- [Exercises:Regular Expressions](#exercisesregular-expressions)
2485+
- [Promises and Callbacks](#promises-and-callbacks)
2486+
- [Async and Await](#async-and-await)
24882487
- [localStorage](#localstorage)
24892488
- [Setting item to the localStorage](#setting-item-to-the-localstorage)
24902489
- [Getting item from localStorage](#getting-item-from-localstorage)
24912490
- [Clearing the localStorage](#clearing-the-localstorage)
24922491
- [Exercises:Local Storage](#exerciseslocal-storage)
24932492
- [Cookies](#cookies)
2494-
- [Promises and Callbacks](#promises-and-callbacks)
2495-
- [Async and Await](#async-and-await)
24962493
- [JavaScript Tests](#javascript-tests)
24972494
- [JavaScript Interview Questions](#javascript-interview-questions)
24982495
- [Exercises:Cookies](#exercisescookies)

0 commit comments

Comments
 (0)