Javascript
2019-06-20 15:36:01   0  举报             
     
         
 AI智能生成
  js自学
    作者其他创作
 大纲/内容
  Have you ever read any part of the JS specification?  
     基础    
     值    
     Number    
     运算    
     浮点数运算  
     大数运算  
     精确计算  
     科学计数法问题  
     String  
     宿主环境下    
     V8引擎    
     单线程  
     单调用栈  
     异步过程    
     EventLoop    
     原理    
     执行过程    
     引擎接收代码  
     函数调用栈优先执行    
     其中可以发起异步事件  
     发起的异步事件要等函数调用站执行完毕  
     引入概念 asynchronous  callback  
     调用栈stack中 使用 web api xhr,setTimeout, 在Web API 中执行,执行完毕之后 将callback 放入 task quene  
     子主题  
     测试    
     简单的eventLoop  
     资料    
     Philip Roberts Help I'm stuck in an event loop
  
     异步    
     JavaScript 引擎本身也可以发起任务了:promise
  
     宿主发起的任务    
     宏观任务  
     JS引擎发起的    
     微观任务  
     JavaScript 引擎等待宿主环境分配宏观任务
  
     宏观任务下 也可以发起promise, js必须保证其在一个宏观任务中完成  
     每个宏观任务又包含了一个微观任务队列  
     Types    
     Primitive Types    
     有哪些    
     undefined  
     string  
     number  
     boolean  
     object  
     symbol  
     各种类型判断    
     哪些场景需要类型判断?  
     typeof 不靠谱  
     其他的方案  
     Abstract Operation  
     coercion  
     equality  
     Typescript flow  
     Scope System  
     Object Basic  
     closure    
     closure is when a function 'remembers' the variables around it even when that function is executed elsewhere  
     keep access alive avoiding grabage collecting  
     函数式    
     摘抄    
     Confidence
  
      the core principles of functional programming   
     make a function a fp function    
     函数有输入输出    
     输入参数    
     判断输入的参数个数    
     However, I suggest that arguments.length, and only that, is OK to keep using for those cases where you need to care about the passed number of arguments. A future version of JS might possibly add a feature that offers the ability to determine the number of arguments passed without consulting arguments.length; if that happens, then we can fully drop usage of arguments!  
     剩余扩展符处理超出个数的  
     具名参数不需要管参数的输入顺序了  
     输出    
     return 也是 flow control的一种  
     拥有多return的函数 也就拥有了多个输出出口    
     Rather than returning from the function early, we used normal flow control (if logic) to determine the retValue's assignment. At the end, we simply return retValue.  
     I'm not unconditionally saying that you should always have a single return, or that you should never do early returns, but I do think you should be careful about the flow control part of return creating more implicitness in your function definitions. Try to figure out the most explicit way to express the logic; that will often be the best way.  
     no implicit output    
     use return to make explicit output  
     容易产生副作用    
     JavaScript uses references and reference-copies for arrays, objects, and functions, so we may create an accidental output from our function all too easily.  
     匿名函数    
     不便于debug  
     可读性也差  
     箭头函数 lexically anonymous    
      I cannot abide by the loss of naming. It's harder to read, harder to debug, and impossible to self-reference.  
      lets us use simple function expressions much like we'd use lazy expressions -- another favorite of the FPer.  
     Declarative Style    
      declarative code communicates more effectively than imperative code  
      we should be striving for declarative, self-explanatory code  
     Name every single function    
     In my practice, if I don't have a good name to use for a function, I name it TODO initially. I'm certain that I'll at least catch that later when I search for "TODO" comments before committing code.  
     管理输入    
     for stylistic purposes of readability, sometimes you'll want to define functions in a way that hides their inputs entirely!  
     多参数转单参数    
     例子    
     ["1","2","3"].map( parseInt );    
     辅助函数1  
     辅助函数2  
     (v)=>(v)    
     例子  
     例子2 在转化函数中作为默认函数  
     var constant =
v =>
() =>
v;
    v =>
() =>
v;
 some now some later    
     wrap function     
      partial application of the ajax(url,data,cb) function  
     Reversing Arguments    
     例子  
     函数组合    
     out to input    
     也就是这样  
     compound function  
     or make a compose2 function    
     var uniqueWords = compose2( unique, words );  
     make a general compose function  
     可以先用大的wrapper 将多个函数的组合 包裹 相当于一个包装 供外界嗲用    
     而多个函数的组合相当于计算步骤  
     并发    
     Event Loop  
    
 
 
 
 
  0 条评论
 下一页