(Welcome! &)
React Week 01
Consent for Audio Recording
WELCOME!
01
02
03
04
05
06
Introduction
JS Recap
Break!
JS Recap
JS Recap
Questions!
var / let / const
15 min
10 min
40 min
modules, imports & exports
25 min
5 min
40 min
Arrow functions
01 Introduction
Know Your Teachers
Anil
Carolyn
Eric
Firas
James
Mojgan
Peter
Sara
Shauna
Tiago
Redi Team
Carys
Fadi
Manu
Course Schedule
Course Structure
Practical Things
Communication
What is React?
React Alternatives
Questions?
JS Recap - var / let / const
Modern JavaScript / ES2015+
Javascript (or ECMAScript) Versions
Edition | Date published | Name |
1 | June 1997 | |
2 | June 1998 | |
3 | December 1999 | |
4 | -- Abandoned -- | |
5 | December 2009 | |
5.1 | June 2011 | |
6 | June 2015 | ECMAScript 2015 (ES2015) |
7 | June 2016 | ECMAScript 2016 (ES2016) |
8 | June 2017 | ECMAScript 2017 (ES2017) |
9 | June 2018 | ECMAScript 2018 (ES2018) |
10 | June 2019 | ECMAScript 2019 (ES2019) |
11 | June 2020 | ECMAScript 2020 (ES2020) |
Datatypes in JS
Datatypes in JS
Source: justjavascript.com
var / let / const
var / let / const
Variable Scope
var / let / const
Redeclaring
var / let / const
Reassignment
const - Primitive Values vs. Objects
const
with
Objects
var / let / const - Semantic Perspective
var / let / const - Summary
Questions?
Break!
JS Recap - Arrow Functions
Template Literals
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.�They were called "template strings" in prior editions of the ES2015 specification.�
�
Syntax: �
The problem
Here’s a situation that comes up all the time: You need to build a URL. In this case, you’re building a link to an image on a cloud service. Your cloud service is pretty great, though. In addition to hosting the asset, you can pass query parameters that will convert the asset in a variety of ways (height, width, and so on).
😬 URLs get particularly ugly because you have to add slashes between the parts of a route along with the building blocks of queries such as ?, =, and &. Traditionally, you have to combine each piece with a + sign.
Alternatively with Template Literals
JS Recap - Arrow Functions
Arrow Function
In JavaScript, you see a lot of callback functions. Those are functions that are passed as a parameter to other functions. Most of the loops you’re about to learn depend on callbacks.
Like most pre-ES6 code, functions are wordy. You have to explicitly declare that you’re creating a function with the function keyword, add curly braces to signify the body, use return statements to end the function, and so on. It’s not unusual for the callback to be longer than the function you inject it into
• The word function
• Name of the function�• Parentheses around arguments
• The word return
• Curly braces
👀
😱 So much extraneous information in a function !� It turns out, we can communicate a function without them.
🙂 Here’s a simple function that takes an argument and returns a slightly modified value. In this case, it takes a name and returns the name with a capitalized first letter.
😊 Here’s the same function as an anonymous function.
Everything is the same except you’re assigning it to a variable.
🤩 An arrow function version uses the same idea: an anonymous function you assign to a variable. You can remove the function keyword and replace it with a fat arrow.
😎 As a bonus, if you have exactly one parameter (which will be the case for many array methods), you can dispense with the parentheses.
JS Recap - Modules, import & export
Modules
In React projects (and actually in all modern JavaScript projects), you split your code across multiple JavaScript files - so-called modules. You do this, to keep each file / module focused and manageable.
To still access functionality in another file, you need export (to make it available) and import (to get access) statements.