본문 바로가기

전체 글

(22)
! [rejected] master -> master (non-fast-forward)error: failed to push some refs to git push를 하다보면 심심찮게 등장한다. 해결방법은 간단하다. (원격저장소가 알맞고, 팀 워킹이 아니라 나 혼자 작업해서 git pull 할 필요 없는 경우) 원인 README.md or .gitignore 해결방법 브랜치 이름 앞에 '+'를 붙이면 된다. -> git push -u origin +master
[JavaScript] classList.toggle 기능 - classList.toggle: toggle('~~'): '~~'가 있으면 classList에서 없애고, 없으면 만들어준다. -> 상황을 가정할 필요 없이 toggle달면 편한 이유 // =========== Selecting elements =========== const player0El = document.querySelector('.player--0'); const player1El = document.querySelector('.player--1'); // 43 const score0El = document.querySelector('#score--0'); const score1El = document.getElementById('score--1'); // const score1 = docu..
[JavaScript] 81. keyup keypress keydown 차이 1) keyup: happens when we lift or finger off the keyboard or off the key 키보드에서 손을 땠을 때 2) keypress: when we keep our finger on a certain key 키보드를 눌렀을 때, 누르고 있을 때 계속 실행 3) keydown: as soon as we just press down the key. so ususally that is the one that we use 키보드를 눌렀을 때, 누르고 있을 떄 한번 실행 -> 대부분 keydown 사용 document.addEventListener('keydown', function (e) { // console.log(e.key); if (e.key === 'Esca..
[JavaScript] HTML structure 자동 설정 (vs code) '!'를 누른후 'tab'키를 누르면 관련 태그가 다음과 같이 설정된다.
[JavaScript] function, function() 차이 JS에서는 함수를 주고 받는 과정이 빈번하다. 그러다보면 function, function()을 쓰게 된다. addEventListenr('click', function)이 맞지, addEventListenr('click', function())이 아니다. function()를 해버리면, 코드를 실행시킬때 'click'여부와 관계없이 함수가 실행된다. 우리가 원하는 것은 'click'했을 때, function이 실행되는 거지 click 여부와 상관없이 함수가 실행되는 것이 아니다. const modal = document.querySelector('.modal'); // console.log(modal); const overlay = document.querySelector('.overlay'); con..
[JavaScript] value VS. textContent document.querySelector('.guess').value = '' document.querySelector('.guess').textContent = '' Only input elements have a "value". It represent the input data supplied by the user or provided initially by the code. Whereas textContent property sets or returns the text content of the specified node, and all its descendants. 오직 Input elements만 value를 가진다. 다른 elements는 textContent로 수정하면 된다! textCont..
[JavaScript] 55. Setting up prettier and VS code (console.log 단축키) JS에서는 console.log()치기 귀찮을 때가 많습니다. 1. cl만 쳐도 console.log가 나오도록 하는 방법 File → Preferences → User snippets → '이름' snippet Create 'prefix'를 'cl'로, body를 'console.log();'로 설정하면, cl 입력 후 엔터치면 console.log가 입력됨. 2. 'Prettier - Code formatter' Extension 세부 설정 조정 '.prettierrc' 파일 생성 { "singleQuote": true, // prettier 기본설정 더블쿼트 -> 싱글쿼트로 바꿔줌 "arrowParens": "avoid" // arrow 함수 파라미터 괄호 해제 }
[JavaScript] 40. Basic Array Operations(Methods) Array Operation(methods) : unshift, pop, indexOf, includes가 있습니다. // 40. Basic Array Operations(Methods) const friends = ['Kim', 'Lee', 'Park']; // Add Elements const newLength = friends.push('Gang'); console.log(friends); // =>['Kim', 'Lee', 'Park'] console.log(newLength); // -> 4 friends.unshift('John'); console.log(friends); // Remove elements friends.pop(); // Last elements 제거 const popped =..