190509-TIL

2019년에 Hexo 블로그에 쓴 글을 옮겨 왔습니다. 당시 이해를 그대로 두었습니다.

Today I Learned

  • Implemented underscore libray’s last function

    Condition complete

    // Like first, but for the last elements. If n is undefined, return just the
    // last element.
    _.last = function(array, n) {
      return n === undefined ? array[array.length-1] : n > array.length ? array : array.slice(array.length-n, array.length);
    };
  • Studied about JavaScript global variable and let, const keyword variables.