This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const fib = n => { | |
| if (n < 2) { | |
| return 1 | |
| } | |
| return fib(n - 1) + fib(n - 2); | |
| } | |
| //or | |
| const fib = n => n < 2 ? 1 : fib(n - 1) + fib(n - 2); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fib(6) | |
| |---fib(5) | |
| | |---fib(4) | |
| | | |---fib(3) | |
| | | | |---fib(2) | |
| | | | |---fib(1) | |
| | | |---fib(2) | |
| | |---fib(3) | |
| | |---fib(2) | |
| | |---fib(1) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const afib = f => n => { | |
| if (n < 2) { | |
| return 1; | |
| } | |
| return f(n -1) + f(n - 2); | |
| } | |
| //or | |
| const afib = f => n => n < 2 ? 1 : f(n - 1) + f(n - 2); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let m = {}; | |
| const fib = n => { | |
| if (m[n]) { | |
| return m[n]; | |
| } | |
| if (n < 2) { | |
| return 1; | |
| } | |
| m[n] = fib(n-1) + fib(n-2); | |
| return m[n]; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // a function to create realFib function | |
| const makeMemoFib = (f, m = {}) => { | |
| const memoFib = (n) => { | |
| if (m[n]) { | |
| return m[n] | |
| } | |
| const fib = f(memoFib); | |
| m[n] = fib(n); | |
| return m[n]; | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const makeMemoFib = (f, m = {}) => { | |
| return (n) => { | |
| if (m[n]) { | |
| return m[n] | |
| } | |
| m[n] = f(makeMemoFib(f, m))(n); | |
| return m[n]; | |
| }; | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const makeMemoFib = (f, m = {}) => (n) => { | |
| if (m[n]) { | |
| return m[n] | |
| } | |
| m[n] = f(makeMemoFib(f, m))(n); | |
| return m[n]; | |
| }; | |
| // simplify again | |
| const makeMemoFib = (f, m = {}) => (n) => { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> | |
| <center> | |
| <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="backgroundTable"> | |
| <tr> | |
| <td>姓名</td> | |
| <td>*|NAME|*</td> | |
| </tr> | |
| <tr> | |
| <td>電話</td> | |
| <td>*|PHONE|*</td> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var car = { | |
| wheel: 3, | |
| speed: () => console.log('fast') | |
| } | |
| var car1 = Object.create(car) | |
| var car2 = Object.create(car) | |
| car1.speed() | |
| car2.speed() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var car = { | |
| wheel: 3, | |
| speed: () => console.log('fast') | |
| } | |
| var car1 = Object.create(car) | |
| var car2 = Object.create(car) | |
| var car3 = Object.assign({}, car) | |
| var car4 = Object.assign(car) | 
OlderNewer