Open DanKim0213 opened 1 year ago
statement vs declaration "You can see declarations as "binding identifiers to values", and statements as "carrying out actions"."
"All declarations (var, let, const, function, function*, class) are "hoisted" in JavaScript."
JavaScript has the following kinds of scopes:
In addition, variables declared with let or const can belong to an additional scope:
MDN TODO:
class Hello {
constructor() {
this.name = "semi";
}
bloom() {
// this.declare();
// by default, `this` within setTimeout is globalThis.
// setTimeout(this.declare.bind(this), 1000);
setTimeout(() => this.declare(), 1000);
}
declare() {
console.log("hoi hoi", this.name);
}
}
const hello = new Hello();
hello.bloom();
Arrow function expressions should only be used for non-method functions because they do not have their own this. Let's see what happens when we try to use them as methods:
TODO: However, because it is a closure, not the function's own binding, the value of this will not change based on the execution context.
Arrow function properties are often said to be "auto-bound methods", because the equivalent with normal methods is:
According to MDN - Event Loop:
JavaScript has a runtime model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks.
https://www.javascripttutorial.net/what-is-javascript/ https://www.javascripttutorial.net/javascript-event-loop/
JavaScript is a single-threaded programming language. This means that JavaScript can do only one thing at a single point in time.
JavaScript
Javascript concept hierarchy I referred to MDN javascript guide
Hierarchy
TODO list