본문 바로가기
Work

다시 시작하는 코딩 공부 - 2020/8/2(일) underbar - every~

by SEO Consulting 2020. 8. 3.
728x90

요즘 공부 집중이 잘 안 되서 

이용하는 Pomodoro Timer

 

#공부 집중앱 : Pomodoro Timer

25분 집중, 5분 휴식을 실천하게 해 주는 어플이다.

계획은 최대한 눈에 보이게 구체적으로 적어주는 것이 효과적

 

#다이어그램 그리는 어플: excalidraw.com

 

Excalidraw

Excalidraw is a whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them.

excalidraw.com

오늘은 자바스크립트 언더바 관련 공부 하는 중. 

https://repl.it/@JINYEONGPARK/underbar2#index.js

원래 계획은 언더바 every 부터 shuffle 까지 끝내고 Data structure 공부를 할 계획이었다. 

 

오늘의 progress와 노트

 

언더바의 spec/SpecRunner을 보면서 하나하나 조건을 만들어 가고, 

디버깅은 크롬 디벨로퍼 source를 이용해서 해 주는 연습.

 

각각의 문제에서 포인트,

 

  • every : 모든 각각의 조건이 다 맞아야 true. (reduce이용)
  • some : 하나만 true여도 true 리턴 (for loop 안에 if절에서 every를 넣어서 하나하나 체크, every 첫 인자로 리스트 형태여야 하는게 포인트)
  • extend : 몇개의 인자가 들어올 지 모르니 arguments를 이용. _.each 안에 arguments를 넣고 각각의 element를 for key in loop을 이용해서 obj안에 키와 밸류를 넣어줌. 그리고 마지막에 obj 리턴

 

  • default: extend와 거의 비슷한데 키가 같을 경우 업데이트 안 시켜 줌, 조건에서 !obj[key] 아니라 obj[key] === undefined 이용

 

 

언더바에서 가장 중요한 once와 memoize *

  • once
  • memoize

_once 함수 안에 나온 func.apply(this, arguments)

  • .apply  : 

func.apply(thisArg, [ argsArray])

 

With the apply() method, you can write a method that can be used on different objects.

The apply() method calls a function with a given this value, and arguments provided as an array (or an array-like object).

 

example1. 

var person = {
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
}
var person1 = {
  firstName: "Mary",
  lastName: "Doe"
}
person.fullName.apply(person1);  // Will return "Mary Doe"

 

example2. 

var person = {
  fullName: function(city, country) {
    return this.firstName + " " + this.lastName + "," + city + "," + country;
  }
}
var person1 = {
  firstName:"John",
  lastName: "Doe"
}
person.fullName.apply(person1, ["Oslo", "Norway"]);

 

  • delay
  • shuffle

 

728x90

댓글