WIL 23-05-28

level·2023년 5월 28일

TIL

목록 보기
12/95

1. 4주차, 5주차 2회독 및 예제 해결
2. 헷갈리는 메서드 연습
3. GIT 오류 해결 및 연습


1.

(1) week4

  • Promise
function fetchAndPrintJson(url) {
  return fetch(url)
    .then((response) => {
			return response.json()
		})
    .then((data) => {
	      console.log(data);
    });
}

fetchAndPrintJson('https://jsonplaceholder.typicode.com/posts/1');
  • async/await
async function fetchJson(url) {
  const response = await fetch(url);
  const data = await response.json();
  console.log(data);
}

fetchJson('https://jsonplaceholder.typicode.com/posts/1');

(2) week5

  • DOM API
const id = button.parentNode.parentNode.id;
  • class
console.log(`영화 제목은 ${this._title}, 감독은 ${this._director}, 개봉연도는 ${this._releaseYear} 입니다.`);
	}

if (typeof newTitle !== 'string') {
      console.log(`영화제목의 data type은 string 이어야 합니다. 현재 타입: ${typeof newTitle}`)
      return;
    } else if (newTitle.length == 0) {
      console.log(`한 글자 이상의 문자열을 할당해 줘야 합니다.`)
      return;
    }
    this._title = newTitle;

2.

  • array.filter()
    filter() 메서드는 ()안의 함수의 조건을 통과하는 모든 요소를 모아 새로운 배열로 반환한다
    [사용 예]
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// Expected output: Array ["exuberant", "destruction", "present"]
  • array.forEach()
    forEach() 메서드는 주어진 함수를 배열 요소 각각에 대해 실행한다
    [사용 예]
const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element));

// Expected output: "a"
// Expected output: "b"
// Expected output: "c"
  • Object.assign()
    Object.assign() 메서드는 출처 객체의 속성들을 다 복사해서 붙여넣은 객체를 반환한다
    [사용 예]
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };

const returnedTarget = Object.assign(target, source);

console.log(target);
// Expected output: Object { a: 1, b: 4, c: 5 }

console.log(returnedTarget === target);
// Expected output: true

3.

  • git 오류 해결
    레파지토리 연동시킨 폴더 위치 잘못 됨
    연동폴더>작업폴더 인 상황에서 작업폴더를 vscode에서 연 상태로 터미널에서 git push 시도하니까 작업폴더에 연결된 origin이 없는데? 상태가 됨
    상위 연동폴더에서 터미널 열고 push 성공

  • branch, merge 연습

git add .(파일만 올릴거면 해당 파일이름)
git commit -m "commit message"
git checkout -b branch 브랜치이름
git push origin 브랜치이름

pull request
merge
  • fork
    해당 레파지토리에서 fork
  • clone
    code-> ssh 주소 복사 -> git clone 주소

0개의 댓글