fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,29 @@
---
title: Map
---
## Map
A map of `[key, value]` entries, where keys and values can be any value (both objects and primitive values).
## Syntax
```javascript
new Map([iterable])
```
## Parameters
**iterable** An Array or other iterable object whose elements are key-value pairs.
## Example
```javascript
// basic usage
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.get('foo'); // returns 1
myMap.get('baz'); // returns 3
myMap.get('hihi'); // return undefined
myMap.size(); // 3
```

View File

@@ -0,0 +1,29 @@
---
title: Map.prototype.clear
---
## Map.prototype.clear
Removes all elements from a `Map` object. Returns `undefined`.
##Syntax
```javascript
myMap.clear();
```
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.size(); // 3
myMap.has('foo'); // true;
myMap.clear();
myMap.size(); // 0
myMap.has('foo'); // false
```

View File

@@ -0,0 +1,33 @@
---
title: Map.prototype.delete
---
## Map.prototype.delete
Removes the specified element from a `Map` object.
Returns whether the key was found and successfully deleted.
## Syntax
```javascript
myMap.delete(key);
```
## Parameters
**key** Required.
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.size(); // 3
myMap.has('foo'); // true;
myMap.delete('foo'); // Returns true. Successfully removed.
myMap.size(); // 2
myMap.has('foo'); // Returns false. The "foo" element is no longer present.
```

View File

@@ -0,0 +1,27 @@
---
title: Map.prototype.entries
---
## Map.prototype.entries
Returns a new `Iterator` object that contains the `[key, value]` pairs for each element in the `Map` object in insertion order.
## Syntax
```javascript
myMap.entries()
```
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
var iterator = myMap.entries();
console.log(iterator.next().value); // ['foo', 1]
console.log(iterator.next().value); // ['bar', 2]
console.log(iterator.next().value); // ['baz', 3]
```

View File

@@ -0,0 +1,34 @@
---
title: Map.prototype.forEach
---
## Map.prototype.forEach
Executes the provided function once per each key/value pair in the `Map` object, in insertion order.
Returns `undefined`.
## Syntax
```javascript
myMap.forEach(callback, thisArg)
```
## Parameters
**callback** Function to execute for each element.
**thisArg** Value to use as this when executing callback.
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
function valueLogger(value, key, map){
console.log(`${value}`);
}
myMap.forEach(valueLogger);
// 1
// 2
// 3
```

View File

@@ -0,0 +1,26 @@
---
title: Map.prototype.get
---
## Map.prototype.get
Returns a value of the specified key from a `Map` object.
## Syntax
```javascript
myMap.get(key);
```
## Parameters
**key** Required.
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.get('foo'); // returns 1
myMap.get('baz'); // returns 3
myMap.get('hihi'); // return undefined
```

View File

@@ -0,0 +1,46 @@
---
title: Map.prototype.has
---
## Map.prototype.has
Given a `Map` with elements inside, the `has()` function allows you to determine whether or not an element exists inside the Map, based on a key that you pass.
The `has()` function returns a _`Boolean` primitive_ (either `true` or `false`), which indicates that the Map contains the element or not.
You pass a `key` parameter to the `has()` function, which will be used to look for an element with that key inside the Map.
Example:
```js
// A simple Map
const campers = new Map();
// add some elements to the map
// each element's key is 'camp' and a number
campers.set('camp1', 'Bernardo');
campers.set('camp2', 'Andrea');
campers.set('camp3', 'Miguel');
// Now I want to know if there's an element
// with 'camp4' key:
campers.has('camp4');
// output is `false`
```
The `campers` Map does not currently have an element with a `'camp4'` key. Therefore, the `has('camp4')` function call will return `false`.
```js
// If we add an element with the 'camp4' key to the map
campers.set('camp4', 'Ana');
// and try looking for that key again
campers.has('camp4');
// output is `true`
```
Since the map now does have an element with a `'camp4'` key, the `has('camp4')` function call will return `true` this time!
In a more real-world scenario, you might not manually add the elements to the Map yourself, so the `has()` function would become really useful in those cases.
#### More Information:
- [Map.prototype.has() on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)

View File

@@ -0,0 +1,25 @@
---
title: Map.prototype.keys
---
## Map.prototype.keys
Returns a new `Iterator` object that contains the keys for each element in the `Map` object in insertion order.
## Syntax
```javascript
myMap.keys()
```
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
const iterator = myMap.keys();
console.log(iterator.next().value); // 'foo'
console.log(iterator.next().value); // 'bar'
console.log(iterator.next().value); // 'baz'
```

View File

@@ -0,0 +1,30 @@
---
title: Map.prototype.set
---
## Map.prototype.set
Sets or updates an element with specified key and value to a `Map` object. Returns `map` object.
## Syntax
```javascript
myMap.set(key, value);
```
## Parameters
**key** Required.
**value** Required.
##Example
```javascript
const myMap = new Map();
// sets new elements
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
// Updates an element
myMap.set('foo', 100);
myMap.get('foo'); // returns 100
```

View File

@@ -0,0 +1,21 @@
---
title: Map.prototype.size
---
## Map.prototype.size
Returns the number of elements in a `Map` object.
## Syntax
```javascript
myMap.size();
```
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.size(); // 3
```

View File

@@ -0,0 +1,24 @@
---
title: Map.prototype.values
---
## Map.prototype.values
Returns a iterator object that contains the values for each element in the `Map` object in insertion order.
## Syntax
```javascript
myMap.values()
```
##Example
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
const iterator = myMap.values();
console.log(iterator.next().value); // 1
console.log(iterator.next().value); // 2
console.log(iterator.next().value); // 3
```