π Intro
This post covers the basics of JavaScript together with the new concepts and lessons learned during this part of the course.
π‘ New concepts
Variables
- const:
The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned. - let:
The let statement declares a block-scoped local variable, optionally initializing it to a value.
Arrays
- Concat():
The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array. - Destructuring assignment:
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
Objects
- Object literal:
An object literal is a list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ({}). - Object methods and βthisβ:
A method is a function which is a property of an object. It is called using the syntax objectName.methodName(). In a method, this refers to the owner object. In other words, this.firstName means the firstName property of this object. More details - Bind:
The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called. More details
π Lessons learned
- There are many similarities between JavaScript and Python, such as the syntax of for loop, functions like
map
,reduce
, etc. However, there are also many differences between them, such as the way of declaring variables, the way of creating functions, etc. In short, the syntax of JavaScript is slightly a confusing thing for me so far when, unfortunately, everytime Python comes to my mind first. At the moment theyβre like two angles fighting in my headβ¦π
π Course exercise
- A simple React app that displays some contents of courses. Link to the repo