-
Notifications
You must be signed in to change notification settings - Fork 0
Javascript concepts
-
primitive types: Boolean, null, undefined, String, and Number
-
Reference types: Array, Function, and Object.
-
functions creates a new variables for each parameter
-
equality operators == and ===
Scope refers to the visibility of variables
- let and const keeps the scope
Context refers to the value of this in the same scope (window obj in browser and node obj in app)
- new logFunc() // creates a local context appoint to the same function
- if / switch / for /while don’t create contexts so the context will be the same as it’s parent
*JavaScript is a single-threaded language so it can only execute a single task at a time. The rest of the tasks are queued in the Execution Context.
(function(){ alert("Name: " + name); }());
node move the declarations to the top using the browser or node memory space *To avoid hoisting use anonymous function
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). *Functions that returns functions *closure are promises? Promises are a different concept *Understand that closures allow data hiding, memoization, and dynamic function generation.
- The JavaScript this keyword refers to the object it belongs to:
- in global object refers to window or node object.
- in a method the class
- in a function, this refers to the global object (if it's not strict mode, otherwise is undefined).
- In an event, this refers to the element that received the event.
- Methods like call(), and apply() can refer to any object.
It creates the local this point and adds proto functionalities like a constructor for instance.
- Call you pass as argument the obj that you want as a context from a method - method.call(myNewContext)
- Apply is the same thing as call but you must send the parameters as a list.
- Bind is the same as call but returns the method instead of call it.
Pure Functions
Summary of knowledges while I'm studying