Recipes - weliame/MyDoc GitHub Wiki

  • Scaffolding file
  • Bubble event
  • Callback
  • Fallback
  • self invoking anonymous function expression
(function() {
  // ...
})(this);

JavaScript variables have either function scope, or global scope. There is no block scope. Enclosing your code in a self invoking function like the one above creates a temporary local scope for single-use, immediately-run code, without polluting the global namespace. 
/** Variables and functions held in the self invoking function cannot be accessed from anywhere else. **/

(this) means pass 'this' to the anonymous function to reference to the global object. In browser scripting the global object has a property named 'window'.
  • Function scope

  • Closures

a closure is an inner object which has access to all of the variables available in its parent function

  • Encapsulation in JS !!

  • Prototypal Inheritance by Douglas Crockford

  • OOP in javascript !!

  • Arrow function

  • Arrow function in ES6

  • --> is a 'go to' operator

  • How does 'this' work

  • CDN in js

  • AMD in JS

  • module.export, export default, exports.module Suppose we have src/grid_component.jsx, a GridComponent is defined in this file, if use exports.module = GridComponent, we can import as, const GridComponent = require('./src/grid_component.jsx')
    if export default GridComponent, we can import as, const GridComponent = require('./src/grid_component.jsx').default
    if a node package grid-pkg contains GridComponent, we can import as, const GridComponent = require('grid-pkg').GridComponent