diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b148830 Binary files /dev/null and b/.DS_Store differ diff --git a/class1.html b/class1.html index d681249..3b3c996 100644 --- a/class1.html +++ b/class1.html @@ -1,159 +1,197 @@ - - + + - Getting Started with ES6 and ES7 JavaScript + Modern JavaScript, ES6 and beyond - - + + - - + + - - + + - - - - + + + + + - + - - + + - + - - - - - - - -
- - -
- -
-

Getting Started with ES6 and ES7 JavaScript

- ES6 and ES7 Intro Image -

Class 1

-
- - -
-

Welcome!

-

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.

-

 

-

Some "rules"

-
    -
  • We are here for you!
  • -
  • Every question is important
  • -
  • Help each other
  • -
  • Have fun
  • -
-
- - -
-

First Things First

-

Tell us about yourself.

-
    -
  • Who are you?
  • -
  • What do you hope to get out of the class?
  • -
  • If you woke up tomorrow as an animal, what animal would you choose to be and why?
  • -
-
- -
-

First Things First

-

Course Format

- -

 

-

Need help?
Note the resources on the whiteboard

-

Thank you to our wonderful TAs!

- -
- - -
-

Get Started: Tools

-

We'll be using the following tools in class:

-

 

-
    -
  • -
    Environment -
    - -
  • -
  • -
    Command Line Interface (your preference)
    -
      -
    • Terminal, cmd, X11, Git Bash, etc.
    • -
    -
  • -
  • -
    Text Editor (your preference) -
    - -
  • -
- -
- -
-

Optional Activity

-

- - -
    -
  1. Login to http://codepen.io (it's free!)
  2. -
  3. For each CodePen exercise, click Edit on CodePen
  4. -
  5. Click the Fork button at the top
  6. -
  7. Edit away! Your changes will save to a new pen in your CodePen account
  8. -
-

See the Pen Block-scoping: ES5 (Before) by Liz Shaw (@anythingcodes) on CodePen.

- - -
- - +
+ +
+

Modern JavaScript ES6 and beyond

+ GDI Logo +

Class 1

+
+ + +
+

Welcome!

+

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on + instruction.

+

 

+

Some "rules"

+
    +
  • We are here for you!
  • +
  • Every question is important
  • +
  • Help each other
  • +
  • Have fun
  • +
+
+ + +
+

First Things First

+

Tell us about yourself.

+
    +
  • Who are you?
  • +
  • What do you hope to get out of the class?
  • +
  • What is your favorite restaurant or coffee shop in Seattle?
  • +
+
+ +
+

Course Format

+ +

 

+

+ Need help? +
Note the resources on the whiteboard

+

+ Thank you to our wonderful TAs! +

+ +
+ + +
+

Get Started: Tools

+

We'll be using the following tools in class:

+

 

+ + +
+ +
+

Optional Activity

+

+ +

+ + +
    +
  1. Login to + http://codepen.io (it's free!)
  2. +
  3. For each CodePen exercise, click + Edit on CodePen +
  4. +
  5. Click the + Fork button at the top
  6. +
  7. Edit away! Your changes will save to a new pen in your CodePen account
  8. +
+

See the Pen + Block-scoping: ES5 (Before) by Liz Shaw ( + @anythingcodes) on + CodePen.

+ + +
+ + -
-

Background

-
- - - -
-

What is ES6?

-
-
-

📄 Standard:

-
    -
  • ECMAScript, abbreviated ES
  • -
  • Describes features, syntax, and behavior of all implementations
  • -
  • Think of it as a ruleset or blueprint
  • -
-


✍ Implementation:

-
    -
  • JavaScript, the implementation of the ECMAScript standard
  • -
  • Implementations track standards
  • -
-
-
- -
-
- The standard, ECMAScript, is the ruleset, or blueprint -
-
- The implementation, JavaScript, is the language that uses that ruleset's plan, or built house/product -
+

+
✍ Implementation:

+
    +
  • + JavaScript is one implementation of the + ECMAScript standard
  • +
+
+
+ +
+
+ The standard, ECMAScript, is the ruleset, or blueprint +
+
+ The implementation, JavaScript, is the language that uses that ruleset's plan, or built house/product
-

- 📝 We'll implement the new features from versions 6 and 7 of ECMAScript using JavaScript -

+
- -
+ + + +
+

History

+

+ The history of ECMAScript and JavaScript +

+ + + +
-
+ + -
-

Transpiling = Transformation + Compiling

-

 

+
+

Today's Topics

+
    +
  1. Transpiling
  2. +
  3. Let & Const
  4. +
  5. Linters
  6. +
  7. Template Strings
  8. +
  9. Enhanced Object Literals
  10. +
  11. Classes
  12. + +
+ +
+ +
+

Transpiling

+
+ +
+

+ Transpiling = Source-to-source compiling

+

 

+ Transpiling -
-
-

Before: ES6

-
const getMessage = () => 'Hello World';
-
-
-

After: ES5

-
Waiting...
-
+
+
+
+

Before: ES6

+
const getMessage = () => 'Hello World';
-

 

- -
+
+

After: ES5

+
Waiting...
+
+
+

 

+ + + +
+

Benefits to Transpiling

+
    +
  • Browser support + +
  • +
  • No need to wait for browsers/engines to catch up with the ECMAScript specification
  • +
  • Focus on writing clean, easy-to-read code — compile it to a cross-browser-compatible format
  • +
  • JavaScript will continue to + evolve constantly; without transpilation, you'll miss out on innovations that make JavaScript more effective, efficient, + and robust
  • +
+
+ +
+

Transpiling Setup

+

You can set this up on your machine using Node.js. For now, CodePen can use Babel to transpile ES6 for us.

+

+ Using the Babel transpiler in CodePen +

+
+ +
+

Let & Const

+ +
+ +
+

Scopes 🔬

+
    +
  • + Until ES6 JavaScript only had global and function level scope +
    function func() {
    +  // function required
    +}
    +
  • +
  • + +
  • +
+

+ var + only respects function scopes +

+ +
+ +
+

Scopes 🔬

+
    +
  • + Block Scopes (a.k.a. lexical scopes): +
    {
    +  // block is anything within { } that isn't a function or a declaration of an object
     }
    -
    -if (isPhiladelphia) {
    -  var alwaysSunny = true;
    -}
    -
      -
    • Examples: { }, if () { }, for() {}, while() { }, etc.
    • Purpose: Declare variables as close as possible, as local as possible, to where they will be used.
    • -
    -
  • -
  • - Function Scopes: -
    function func() {
    -  // function required
    -}
    -
    • Purpose: Code wrapped in a function effectively "hides" any enclosed variable or function declarations from the outside scope.
    -
  • - -

    var only respects function scopes

    -

    Function vs. Block Scope »

    -
    -
+ + +

+ Function vs. Block Scope » +

+ + + + +
+

+ Let and + Const keywords

+
    +
  • Block-scoped + { }, unlike the function-scoped + var +
  • + +
  • + Let + can be reassigned +
      +
    • New way to declare variables
    • +
    +
  • +
  • + Const + cannot be reassigned +
      +
    • Const stands for constant
    • +
    • Must be initialized on declaration
    • +
    • But... Complex values can be changed +

      + const bindings and reassignments +

      +
    • +
    +
  • +
-
+ + +
+ + -

Instructions can be found by editing the below pen on CodePen. Be sure to fork the pen first if you'd like to save your work to your account!

-
-
-

Activity 1

-

See the Pen Block-scoping by Liz Shaw (@anythingcodes) on CodePen.

- View Solution -
-
-

Activity 2

-

See the Pen Block-scoping with let (Before) by Liz Shaw (@anythingcodes) on CodePen.

- View Solution -
+
+

Activity

+ +

Instructions can be found by editing the below pen on CodePen. Be sure to fork the pen first if you'd like to save your + work to your account!

+
+
+

Activity 1

+

See the Pen + Block-scoping by Liz Shaw ( + @anythingcodes) on + CodePen.

+ View Solution
+
+

Activity 2

+

See the Pen + Block-scoping with let (Before) by Liz Shaw ( + @anythingcodes) on + CodePen.

+ View Solution +
+
- -
+ +
-
+ +
+

Do you still need + var?

+
    +
  • Most popular answer is no, but how do you decide?
  • +
  • Use your team's style guide
  • +
  • Use a popular style like like + Airbnb: +
      +
    • avoid var
    • +
    • use const unless you need to reassign
    • +
    +
  • +
+ +
+ +
+

Linters

+
+ +
+

What is a linter?

+
    +
  • Parser that analyzes your code and looks for mistakes
  • +
  • Can help you: +
      +
    • Develop faster
    • +
    • Keep your code organized
    • +
    • Make fewer syntax errors
    • +
    +
  • +
  • Enforces your team's coding style and makes your code easier to read
  • +
+
-
+
+

ESLint Demo

+
-
-

String Helpers

-
+
+

Template Strings

+
-
+ -
-

Template Strings

-

Allow multi-line strings

-

Great for use with HTML templates

-
-
-

ES5:

-
'
' + +
+

Template Strings

+

Allow multi-line strings

+

Great for use with HTML + templates +

+
+
+

ES5:

+
'
' + '

Hello ' + str + '!

' + '
';
-

becomes

-
-
-

ES6:

-
`
+

becomes

+
+
+

ES6:

+
`

Hello ${str}!

`;
-
- -
+
+ +
+ +
+

Using Template Strings

+
const message = `User ${name} scored ${score} on the exam`;
+

 

+
    +
  • Use backticks ( + ` `) around the string
  • +
  • Use + ${ } around any + variable or + expression +
  • +
  • Work well with + ternary operators, for example +
    + ${ userIsYoungerThan21 ? serveGrapeJuice() : serveWine() } +
  • +
+

 

+
const message = `User ${name} ${score >= 60 ? 'passed' : 'failed'} the exam`;
+ +
+ +
+

Activity

+

Refactor this code to use template strings.

+
+

See the Pen + Template Strings Activity by Liz Shaw ( + @anythingcodes) on + CodePen.

+
+ View Solution + +
+ +
+

Enhanced Object Literals

+ +
+ +
+

Property Initializer Shorthand

+

When an object property name is the same as the local variable name, you can include the name without a colon and value

+
+
+

ES5:

+
function saveData(url, data){
+  $.ajax({ method: 'POST', url: url, data: data });
+}
+

becomes

+
+
+

ES6:

+
function saveData(url, data){
+  $.ajax({ url, data, method: 'POST' });
+}
+
+
+

Sometimes referred to as + enhanced literal notation +

+ +
+ +
+

Concise methods

+

Object methods no longer need + : function +

+
+
+

ES5:

+
var dog = {
+	name: 'Boo',
+	bark: function() {
+	console.log('yip!');
+	}
+};
+dog.bark(); // yip!
+

becomes

+
+
+

ES6:

+
const dog = {
+	name: 'Boo',
+	bark() {
+	console.log('yip!');
+	}
+};
+dog.bark(); // yip!
+
+
+ +
-
-

Using Template Strings

-
const message = `User ${name} scored ${score} on the exam`;
-

 

+
+

Activity

+

Using Enhanced Object Syntax

+ +

See the Pen + Object Syntax by Liz Shaw ( + @anythingcodes) on + CodePen.

+ + View Solution + +
+ +
+

Classes

+
+ + +
+

Classes

+
+
+

ES5:

+
function Vehicle(type) {
+  this.type = type;
+}
+
+Vehicle.prototype.logType = function() {
+  console.log(this.type);
+};
+
+var car = new Vehicle('car');
+car.logType(); // 'car'
+
+console.log(car instanceof Vehicle); // true
+console.log(car instanceof Object); // true
+
+
+
+

ES6:

+
class Vehicle {
+  constructor(type) {
+    this.type = type;
+  }
+
+  logType() {
+    console.log(this.type);
+  }
+}
+const car = new Vehicle('car');
+car.logType(); // 'car'
+
+console.log(car instanceof Vehicle); // true
+console.log(car instanceof Object); // true
+
+
+
+

 

+

You don't need commas between the elements of a class

+ +
+ +
+ +
+

Derived Classes

+

+ Derived classes: Classes that inherit from other classes

+

Within the derived class's + class {} definition, use the + extends keyword to specify the base class. Then access the base class constructor by calling + super().

+
class Rectangle {
+  constructor(length, width) {
+    this.length = length;
+    this.width = width;
+  }
+
+  getArea() {
+    return this.length * this.width;
+  }
+}
+
+
class Square extends Rectangle {
+  constructor(length) {
+    super(length, length); // calls the base class constructor
+  }
+}
 
-				
-

Activity

-

Refactor this code to use template strings.

-
-

See the Pen Template Strings Activity by Liz Shaw (@anythingcodes) on CodePen.

+const square = new Square(5); +console.log(square.getArea()); // 25 +
+ +
+ +
+

Activity

+

Classes and Derived Classes

+
+
+

Activity 1

+

See the Pen + Classes by Liz Shaw ( + @anythingcodes) on + CodePen.

+

+ View Solution +

- View Solution - -
+
+

Activity 2

+

See the Pen + Shop Activity - Classes and Derived Classes by Liz Shaw ( + @anythingcodes) on + CodePen.

+ View Solution +
+
+ + +
+

Optional Activity

+ Practice Test Driven Development with http://es6katas.org/ +
-
-

At-Home Challenge

-

Fruit Basket

-
-
-
var fruit = 'apple';
+			
+

At-Home Challenge

+

Fruit Basket

+
+
+
var fruit = 'apple';
 
 (function basket(){
     var fruit = 'banana';
@@ -598,76 +1027,82 @@ 

Fruit Basket

fruitBasket.getFruit(); console.log(fruit);
-
-
-

What would the following output to the console and why?

-
- - -
- - -
-

Next Week

-
    -
  • Review at-home challenge from today's class
  • -
  • Arrow Functions
  • -
  • Arrow Functions and this
  • -
  • Array Helpers
  • -
  • Altering Arrays
  • -
- -

 

-

Remember to do the at-home challenge!

-
-
-

Questions

-
? -
+
+

What would the following output to the console and why?

- -
+
+ + +
+ + +
+

Next Week

+
    +
  • Review at-home challenge from today's class
  • +
  • Arrow Functions
  • +
  • Arrow Functions and + this +
  • +
  • Array Helpers
  • +
  • Altering Arrays
  • +
+ +

 

+

+ Remember to do the at-home challenge! +

+
+
+

Questions

+
? +
+
+ +
-
-
+ + - - - - - - - - - - - +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/class2.html b/class2.html index 5c7691d..96a1125 100644 --- a/class2.html +++ b/class2.html @@ -51,8 +51,8 @@

Getting Started with ES6 and ES7 JavaScript

- ES6 and ES7 Intro Image -

Class 2

+ GDI Logo +

Class 2

@@ -1503,7 +1503,6 @@

Questions

diff --git a/class3.html b/class3.html index 32aa661..b5c7978 100644 --- a/class3.html +++ b/class3.html @@ -51,8 +51,8 @@

Getting Started with ES6 and ES7 JavaScript

- ES6 and ES7 Intro Image -

Class 3

+ GDI Logo +

Class 3

@@ -60,7 +60,6 @@

Today's Topics

  1. Review at-home challenges from last class
  2. Function Parameters
  3. -
  4. Object Syntax
  5. Destructuring Objects
  6. Destructuring Arrays
@@ -451,72 +450,6 @@

Activity 2

-
-

Object Syntax

- -
- -
-

Property Initializer Shorthand

-

When an object property name is the same as the local variable name, you can include the name without a colon and value

-
-
-

ES5:

-
function saveData(url, data){
-  $.ajax({ method: 'POST', url: url, data: data });
-}
-

becomes

-
-
-

ES6:

-
function saveData(url, data){
-  $.ajax({ url, data, method: 'POST' });
-}
-
-
-

Sometimes referred to as enhanced literal notation

- -
- -
-

Concise methods

-

Object methods no longer need : function

-
-
-

ES5:

-
var dog = {
-  name: 'Boo',
-  bark: function() {
-    console.log('yip!');
-  }
-};
-dog.bark(); // yip!
-

becomes

-
-
-

ES6:

-
const dog = {
-  name: 'Boo',
-  bark() {
-    console.log('yip!');
-  }
-};
-dog.bark(); // yip!
-
-
- -
- -
-

Activity

-

Using Enhanced Object Syntax

- -

See the Pen Object Syntax by Liz Shaw (@anythingcodes) on CodePen.

- - View Solution - -
-

Destructuring Objects

@@ -881,7 +814,6 @@

Questions

diff --git a/class4.html b/class4.html index 7e4f8b5..9c46fc6 100644 --- a/class4.html +++ b/class4.html @@ -51,8 +51,8 @@

Getting Started with ES6 and ES7 JavaScript

- ES6 and ES7 Intro Image -

Class 4

+ GDI Logo +

Class 4

@@ -65,7 +65,6 @@

Today's Topics

  • Generator Functions
  • Iterables
  • Sets and Maps
  • -
  • Classes
  • Encapsulating Code with Modules
  • Transpiling Setup
  • Additional Resources
  • @@ -797,107 +796,6 @@

    Built-In Iterators

    -
    -

    Classes

    -
    - -
    -

    Classes

    -
    -
    -

    ES5:

    -
    function Vehicle(type) {
    -  this.type = type;
    -}
    -
    -Vehicle.prototype.logType = function() {
    -  console.log(this.type);
    -};
    -
    -var car = new Vehicle('car');
    -car.logType(); // 'car'
    -
    -console.log(car instanceof Vehicle); // true
    -console.log(car instanceof Object); // true
    -

    called "creating a custom type"

    -
    -
    -

    ES6:

    -
    class Vehicle {
    -  constructor(type) {
    -    this.type = type;
    -  }
    -
    -  logType() {
    -    console.log(this.type);
    -  }
    -}
    -const car = new Vehicle('car');
    -car.logType(); // 'car'
    -
    -console.log(car instanceof Vehicle); // true
    -console.log(car instanceof Object); // true
    -
    -
    -

     

    -

    You don't need commas between the elements of a class

    - - -
    - -
    -

    Derived Classes

    -

    Derived classes: Classes that inherit from other classes

    -

    Within the derived class's class {} definition, use the extends keyword to specify the base class. Then access the base class constructor by calling super().

    -
    class Rectangle {
    -  constructor(length, width) {
    -    this.length = length;
    -    this.width = width;
    -  }
    -
    -  getArea() {
    -    return this.length * this.width;
    -  }
    -}
    -
    class Square extends Rectangle {
    -  constructor(length) {
    -    super(length, length); // calls the base class constructor
    -  }
    -}
    -
    -const square = new Square(5);
    -console.log(square.getArea()); // 25
    - - - -
    - -
    -

    Activity

    -

    Classes and Derived Classes

    -
    -
    -

    Activity 1

    -

    See the Pen Classes by Liz Shaw (@anythingcodes) on CodePen.

    -

    View Solution

    -
    -
    -

    Activity 2

    -

    See the Pen Shop Activity - Classes and Derived Classes by Liz Shaw (@anythingcodes) on CodePen.

    - View Solution -
    -
    -
    -

    Encapsulating Code with Modules

    @@ -1037,7 +935,6 @@

    Thank you all!

    diff --git a/dist/.DS_Store b/dist/.DS_Store new file mode 100644 index 0000000..e893616 Binary files /dev/null and b/dist/.DS_Store differ diff --git a/dist/img/.DS_Store b/dist/img/.DS_Store new file mode 100644 index 0000000..df6014c Binary files /dev/null and b/dist/img/.DS_Store differ diff --git a/dist/img/functional-scope.png b/dist/img/functional-scope.png new file mode 100644 index 0000000..64a0239 Binary files /dev/null and b/dist/img/functional-scope.png differ diff --git a/dist/img/js-es5-scope-2.png b/dist/img/js-es5-scope-2.png new file mode 100644 index 0000000..caaa3ad Binary files /dev/null and b/dist/img/js-es5-scope-2.png differ diff --git a/dist/img/scope_diagram.png b/dist/img/scope_diagram.png new file mode 100644 index 0000000..42d410c Binary files /dev/null and b/dist/img/scope_diagram.png differ diff --git a/index.html b/index.html index 822ff1a..2bc65e2 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Getting Started with ES6 and ES7 JavaScript + Modern JavaScript, ES6 and beyond @@ -50,7 +50,7 @@
    -

    Getting Started with ES6 and ES7 JavaScript

    +

    Modern JavaScript, ES6 and beyond

     

    @@ -66,7 +66,7 @@

    Getting Started with ES6 and ES7 JavaScript