Skip to content

Commit

Permalink
Add all code tidbits
Browse files Browse the repository at this point in the history
  • Loading branch information
Samantha Ming committed May 12, 2018
0 parents commit 08e6882
Show file tree
Hide file tree
Showing 33 changed files with 599 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .gitignore
@@ -0,0 +1,58 @@

# Created by https://www.gitignore.io/api/git,macos,windows

### Git ###
*.orig

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk


# End of https://www.gitignore.io/api/git,macos,windows

/template.md
32 changes: 32 additions & 0 deletions 1-convert-to-true-array.md
@@ -0,0 +1,32 @@
# Convert Array-like to True Array

This is cool! Learning something new @wesbos ES6 course 🔥


```javascript
const nodeList = document.querySelectorAll('ul li');

// Method 1: Convert to true Array
Array.from(nodeList);

// Method 2: Convert to true Array
[...nodeList];

// Now you can use map and other methods to loop
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/962414853607444480)**

**[Instagram](https://www.instagram.com/p/BfB23phgsOI/?taken-by=samanthaming)**


## Resources

- https://github.com/wesbos/es6-articles/blob/master/25%20-%20Array.from()%20and%20Array.of().md


## Image Download

![Download](1-convert-to-true-array.png)
Binary file added 1-convert-to-true-array.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions 10-remove-array-duplicates-using-set.md
@@ -0,0 +1,38 @@
# Remove Array Duplicates Using ES6 Set

Remove Array Duplicates using ES6 Set.

“Set” is a data structure that stores unique values. It doesn’t allow you to add duplicates. This makes it ideal for us to use to remove duplicates from an Array. BUT, Set is not an array, that’s why we need to convert the Set back into an Array in order to use array methods such as .map or .reduce

1. Remove duplicates using “new Set”
2. Convert it back to an array using “Array.from”


```javascript
const duplicates = [1,2,3,4,4,1];

const uniques = Array.from(new Set(duplicates));

console.log(uniques) // [1,2,3,4,1]
```

Alternatively, you can use the spread operator to convert the Set to an Array.

```javascript
const duplicates = [1,2,3,4,4,1];

const uniques = [...new Set(duplicates)];

console.log(uniques) // [1,2,3,4,1]
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/982699751022800897)**

**[Instagram](https://www.instagram.com/p/BhR-XLWA8eF/?taken-by=samanthaming)**


## Image Download

![Download](10-remove-array-duplicates-using-set)
Binary file added 10-remove-array-duplicates-using-set.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions 11-setting-default-parameters.md
@@ -0,0 +1,36 @@
# Setting Default Parameters

Super simple to set Default Parameters with ES6 👏‬

The old way was to use a ternary operator to assign the default value if it was undefined.

With ES6, you can set the default value right inside the function parameters 🎉


```javascript
// Old Way
function coffeeOrTea(drink) {
drink = drink !== undefined ? drink : '🍵';
}

// ES6 Way
function coffeeOrTea2(drink = '🍵') {

}
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/985230884969185281)**

**[Instagram](https://www.instagram.com/p/Bhj9ITfhlNT/?taken-by=samanthaming)**


## Resources

- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters


## Image Download

![Download](11-setting-default-parameters.png)
Binary file added 11-setting-default-parameters.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions 12-split-string-using-spread.md
@@ -0,0 +1,36 @@
# Split String Using ES6 Spread

Split string using ES6 Spread 🎉

Convert a string to an array of characters using the spread syntax!

It goes through each character in the “pizza” string and assigns it to our new “splitPizza” array. Very cool 🤩


```javascript
const pizza = 'pizza';

// Old Way
const slicedPizza = pizza.split('');
console.log(slicedPizza) // [ 'p', 'i', 'z', 'z', 'a' ]

// ES6 Way
const slicedPizza2 = [...pizza];
console.log(slicedPizza2) // [ 'p', 'i', 'z', 'z', 'a' ]
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/987758991026544640)**

**[Instagram](https://www.instagram.com/p/Bh1601FB4KJ/?taken-by=samanthaming)**


## Resources

- https://stackoverflow.com/questions/44900175/why-does-spread-syntax-convert-my-string-into-an-array?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


## Image Download

![Download](12-split-string-using-spread.png)
Binary file added 12-split-string-using-spread.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions 13-skip-values-in-destructuring.md
@@ -0,0 +1,40 @@
# Skip Values In Destructuring

Skip Values in Destructuring 🎉

You can use blanks to skip over unwanted values.

This way you can avoid useless variable assignments for values you don’t want during destructuring 👍


```javascript
// Ugh, useless variable assignments
let [a,b,c] = ['ignore', 'ignore', 'keep'];
console.log(a, b, c); // ignore ignore keep

// Use blanks to skip over unwanted values
let [ , , c2] = ['ignore', 'ignore', 'keep'];
console.log(c2); // keep
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/990301402311348232)**

**[Instagram](https://www.instagram.com/p/BiH_WV8hmHI/?taken-by=samanthaming)**


## Resources

- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values

- http://untangled.io/advanced-es6-destructuring-techniques/

- https://stackoverflow.com/questions/46775128/how-can-i-ignore-certain-returned-values-from-array-destructuring

- http://2ality.com/2015/01/es6-destructuring.html


## Image Download

![Download](13-skip-values-in-destructuring.png)
Binary file added 13-skip-values-in-destructuring.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions 14-combine-multiple-arrays-using-spread.md
@@ -0,0 +1,36 @@
# Combine Multiple Arrays Using Spread

Combine Multiple Arrays using ES6 Spread ‬🤩

Instead of using concat() to concatenate arrays, try using the spread syntax to combine multiple arrays into one flattened array👍


```javascript
let veggie = ['🍅', '🥑'];
let meat = ['🥓'];

// Old Way
let sandwich = veggie.concat(meat, '🍞');
console.log(sandwich); // [ '🍅', '🥑', '🥓', '🍞' ]

// ES6 Way
let sandwich2 = [...veggie, ...meat, '🍞'];
console.log(sandwich2); // [ '🍅', '🥑', '🥓', '🍞' ]
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/992839527969439744)**

**[Instagram](https://www.instagram.com/p/BiaB6mAhc8R/?taken-by=samanthaming)**


## Resources

- https://davidwalsh.name/spread-operator
- https://gist.github.com/yesvods/51af798dd1e7058625f4


## Image Download

![Download](14-combine-multiple-arrays-using-spread.png)
Binary file added 14-combine-multiple-arrays-using-spread.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions 15-4-ways-to-combine-strings.md
@@ -0,0 +1,38 @@
# 4 Ways to Combine Strings

Happy Mother’s Day 🌷

4 ways to combine strings in JavaScript. My favourite way is using ES6’s Template Strings. Why? Because it’s more readable, no backslash to escape quotes, and no more messy plus operators.

```javascript
const mom = '🌷'

// ES6's Template Strings
`Happy Mother's Day ${mom}`

// join() Method
['Happy ', 'Mother\'s ', 'Day ', mom].join('')

// Concat() Method
"".concat('Happy ', 'Mother\'s ', 'Day ', mom)

// + Operator
'Happy Mother\'s Day' + mom
```


## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/995373862148755456)**

**[Instagram](https://www.instagram.com/p/BisCR23B8nT/)**


## Resources

- [MDN Template Literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)


## Image Download

![Download](15-4-ways-to-combine-strings.png)
Binary file added 15-4-ways-to-combine-strings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions 2-console-table.md
@@ -0,0 +1,13 @@
# Use `console.table` to display your data

This is a cool way to display your data in your browser dev tools. Works great with Array and Objects. Instead of console.log, try `console.table` next time ⭐️

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/964174008219418625)**

**[Instagram](https://www.instagram.com/p/BfOVuAggSI1/)**

## Image Download

![Download](2-console-table.png)
Binary file added 2-console-table.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions 3-when-not-to-use-arrow-functions.md
@@ -0,0 +1,30 @@
# When NOT to use Arrow Functions

Arrow functions are terrific, but not suitable for all situations. Avoid them in objects because 'this' is always scoped to the parent -- which is the 'window' in this case.

```javascript

type: '🍔',
eat: () => { // Should use function() instead
console.log(this); // 'this' is Window, not burger
}
}

// Avoid Arrow Functions in Objects
```

## Like this Post

**[Twitter](https://twitter.com/samantha_ming/status/964977650375696384)**

**[Instagram](https://www.instagram.com/p/BfUHooqA1Wc/?taken-by=samanthaming)**


## Resources

- https://wesbos.com/arrow-function-no-no/


## Image Download

![Download](3-when-not-to-use-arrow-functions.png)
Binary file added 3-when-not-to-use-arrow-functions.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 08e6882

Please sign in to comment.