Authored by: Vladimir Dimitrovski, Senior Front-End Developer at InPlayer
- Variables
- Declaring a variable
- Declaring multiple variables
- Assigning a value to a variable: The
=operator - Reading/accessing a variable
- Displaying/printing a variable:
console.log(),alert()etc.
- Displaying/printing a variable:
- Modifying a variable
- Variables with no value:
undefined
- The Global Object or "namespace":
window - Data types
- Primitive data types
- Non-primitive data types
- Primitive data types:
boolean,number,stringundefinedVSnullboolean- Single boolean
- Declaring and assigning a boolean variable:
trueorfalse - Negating a boolean value with NOT: The
!operator
- Declaring and assigning a boolean variable:
- Multiple booleans
- Comparing multiple booleans: The
===and!==operators - Combining multiple booleans with AND: The
&&operator - Combining multiple booleans OR: The
||operator
- Comparing multiple booleans: The
- Single boolean
number- Single number
- Declaring and assigning a number variable
- Incrementing the value of a number variable: The
++operator - Decrementing the value of a number variable: The
--operator
- Multiple numbers
- Comparing multiple numbers: The
===,!==,>,>=,<and<=operators - Adding: The
+operator - Subtracting: The
-operator - Multiplying: The
*operator - Dividing: The
/operator - Bonus
- Remainder of dividing: The
%operator - Exponentiation: The
**operator
- Remainder of dividing: The
- Comparing multiple numbers: The
- The numeric non-value:
NaNNaNas a result from a mathematical operation that is enable to deliver a valid numeric result- Number cannot be parsed: parseInt('blabla') or Number(undefined)
- Math operation where the result is not a real number: Math.sqrt(-1)
- Operand of an argument is
NaN: 7 ** NaN - Dividing by 0: 17 / 0
- Single number
string- Single string
- Declaring and assigning a string variable
- Singleline string with singlequotes
''or doublequotes"" - Multiline string with template strings
- Singleline string with singlequotes
- Declaring and assigning a string variable
- Multiple strings
- Comparing multiple strings: The
===and!==operators - Concatenating multiple strings: The
+operator - The
-operator cannot be used forstrings - Bonus
- Removing and replacing a part of a string with
{string}.replace()
- Removing and replacing a part of a string with
- Comparing multiple strings: The
- Single string
- The "non-type" primitive type:
undefinedundefinedindicates absence of value of any type, it might even mean absence of a placeholder (a variable or an object property) for a value- The
typeofkeyword
- The "non-value" type:
nullnullindicates absence of value of any type, but it's also an indication of a reserved placeholder for a possible value in the future
- Converting a primitive value into a different type of primitive value
- Implicit (automatic) conversion
- Combining values of different types
string+number=number+string=stringstring+boolean=boolean+string=string- Bonus
boolean+number=number+boolean=number
- Combining values of different types
- Explicit conversions
stringtonumber:Number(string)numbertostring:number.toString()andString(number)booleantostring:boolean.toString()andString(boolean)
- Implicit (automatic) conversion
- Conditional Statements
- The
ifkeyword- The condition: It's always converted to a
booleanvalue- Shorthand conditional values: "truthy" and "falsy" values
booleannumberstringundefinedandnull
- Shorthand conditional values: "truthy" and "falsy" values
- The condition: It's always converted to a
elseelse if- Bonus
switch
- The
- Loops
- The
forloop - Bonus
whiledo/while
- The
- Non-primitive data types
function- Declaring a function: The
functionkeyword - Calling/invoking a function: The
()operator - Function arguments
- Calling/invoking a function with an argument
- Calling/invoking a function with multiple arguments
- Function arguments are just local variables inside a function
- Difference between
varandletinside a function - Functions are also just variables
- Assigning a function variable
- Calling/invoking a function variable
- Calling/invoking a function from another function
- Function return value: The
returnkeyword - Bonus
- Self-invoking functions
- Closures
- Declaring a function: The
array- Single
array- Declaring and assigning an
array - Array
indexand elements- Accessing an array element by index
- The traditional way: array[index]
- The modern way: array.at(index)
- Assigning or modifying an array element by index
- Array size: the
.lengthproperty - Find a value inside an array
- Does the array contain a value:
contains() - Find the index of a value inside of an array:
indexOf()
- Does the array contain a value:
- Accessing an array element by index
- Declaring and assigning an
- Multiple
arrays- Comparing multiple
arrays: The===operator
- Comparing multiple
- Single
- Plain
object- Single
object- Declaring and assigning an
object - Object properties
- Object keys and values
- Accessing an object value by key
- The dot way:
object.keyString - The string way:
object['keyString']
- The dot way:
- Declaring and assigning an
- Multiple
objects- Comparing multiple
objects: The===operator
- Comparing multiple
- Single
- Class: The
classkeyword- A class is just a template for creating multiple objects of the same shape, it's an "object creator"
- Comparison: Old syntax VS modern syntax
- The
prototypeobject
- The
- Class members
- Class properties: No different to regular object properties
- Methods: They are just functions
- The
constructormethod - The
thiskeyword inside a class - Bonus
- Class inheritance
- Array methods and properties
- Array size: The
.lengthproperty - Iterating though an
array- Using the
forloop - Loop methods
forEach()map()filter()
- Other methods
join()- Join array values into astring{string}.split()- Split a string into anarray
- Using the
- Array size: The
- The DOM
- The
documentobjectdocument.headanddocument.body- Accessing an element from the DOM
- Single element:
- By id:
document.getElementById(id) - By a query selector (CSS selector):
querySelector(cssSelector)
- By id:
- Multiple elements:
- By tag name:
getElementByTagName(tagName) - By the
classNameattribute:getElementsByClassName(className) - By a query selector (CSS selector):
querySelectorAll(cssSelector)
- By tag name:
querySelectorandquerySelectorAll- By tag name:
querySelector('div') - By id:
querySelector('#myElementId') - By the
classNameattribute:querySelector('.my-element-class') - Bonus
- Refer back to CSS Selectors
- By any other attribute:
querySelector('[attribute-name="attribute-value"]')
- By tag name:
- Single element:
- Elements inside the DOM
- Accessing and modifying an element's content
innerTextinnerHTML
- Accessing and assigning attributes or properties of a DOM element
- Attributes VS properties - what is the difference?
- DOM element VS DOM object
idpropertyclassNamepropertygetAttribute()andsetAttribute()- Refer back to different tags and their specific attributes
- Accessing and interacting with an
inputelement
- Accessing and interacting with an
- The
classListproperty object.add().contains().remove().toggle().replace()
- Attributes VS properties - what is the difference?
- Creating a new element:
document.createElement(tagName) - Adding an element to the DOM
appendChild()prepend()
- Accessing and modifying an element's content
- Events
- Event type
- Event target
- Listen for an event:
element.addEventListener() - Event listeners
- Event listeners are just functions that react to an event
- Event listener's arguments: The
eventobject:typetargetcurrentTarget- Bonus
- Event bubbling
- Stop listening for an event:
element.removeEventListener()
- The
- JavaScript Event Loop
- What is the order of code execution in JavaScript?
- Synchronous code
- Asynchronous code
- The Event Loop queue
setTimeout()andsetInterval()clearTimeout()andclearInterval()Promisesresolveandrejectthenandcatch
- Syntaxic alternative to
Promises:asyncandawaittry/catchblock
- JavaScript Modules
- Overview: Refer back to the Global Object (
window) - The
type="module"attribute of<script></script> - JavaScript Modules are just encapsuled chunks of JavaScript code
- JavaScript modules don't polute the Global Object (
window), avoiding naming conflicts - Refer back to self-closing functions and closures
- Exporting and importing a JavaScript module: The
exportandimportkeywords - Default export and default import: The
export defaultkeyword combination
- JavaScript modules don't polute the Global Object (
- Overview: Refer back to the Global Object (
- JSON data format
- Overview: JSON object side by side a plain JavaScript object
- Converting a JSON into a JavaScript object or array
- Converting a JavaScript object or an array into JSON
Create-React-App- Install
NodeJS - Install
yarn - Installing Node packages
Create React App- Install
- Overview of
Create-React-Appcommands:yarn startandCtr+C - Demonstrate live updating
- Install
- Introduction
- React app root
- Rendering native HTML elements in React
- React component: It can either be a
functionor aclass- Function Component
- Creating an empty function component
- The mandatory
returnstatement - The default
null
- The mandatory
- Render an HTML element into a basic React component
- Render multiple HTML elements into a basic React component
- With wrapping container
- With
React.Fragment(The<></>element)
- Element attributes in HTML = Element props in React
- Event listeners - React VS JavaScript
- Creating an empty function component
- Component props
- Function Component