분류 전체보기(109)
-
Array APIs - indexOf(), lastIndexOf(), includes()
indexOf : 특정한 요소의 위치를 찾을 때 indexOf(searchElement: T, fromIndex?: number): number; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. */ //특정한 요소의 위치를 찾을 때 const bread = ['🍞', '🥖', '🥐', '🥨']; console.l..
2022.10.05 -
Array APIs - splice(), slice(), concat()
splice : 삭제한 배열을 반환하고 기존의 배열을 업데이트함 splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. * @returns An array containing the elemen..
2022.10.05 -
Array APIs - push(), pop(), unshift(), shift()
push : 배열 맨 뒤에 요소 추가 push(...items: T[]): number; /** * Appends new elements to the end of an array, and returns the new length of the array. * @param items New elements to add to the array. */ const animal = ['🐶', '🐱']; animal.push('🐹'); console.log(animal); //['🐶', '🐱', '🐹'] animal.push('🐰', '🐼'); console.log(animal); //['🐶', '🐱', '🐹', '🐰', '🐼'] pop : 배열 마지막 요소 제거 pop(): T | undefined; /** * R..
2022.10.03 -
Array APIs - forEach()
forEach forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function...
2022.10.02 -
유용한 터미널 명령어
자주 사용하는 터미널 CLI(Command Line Interface)에 대해서 알아봅시다. pwd 현재 경로 출력하기 pwd #현재 경로 출력 cd 디렉터리로 이동하기 cd #홈 이동 cd ../ #이전 디렉토리 이동 cd ../../ #이전 이전 디렉토리 이동 cd 하위_디렉토리명 #하위 디렉토리 이동 mkdir 새로운 디렉토리 생성하기 mkdir new_directory_name #새로운 디렉토리 생성 mkdir dir1 dir2 #여러개의 디렉토리 생성 touch 새로운 파일 생성하기 touch new_file_name.txt #현재 경로에서 새로운 파일 생성 echo 지정한 파일에 내용 추가하기 echo hello_world > file_001.txt #지정한 파일에 내용 추가, file_001..
2022.09.29 -
현재 스크롤Y값 구하기
브라우저에서 현재 scrollY 값을 구하는 방법에 대해서 알아보겠습니다. window.pageYOffset === window.scrollY; //true window 안의 document가 수직 방향으로 스크롤된 거리를 픽셀 단위로 나타낸 부동소수점 수를 반환합니다. 단일 픽셀보다 높은 수준의 정밀도를 가지므로 정수가 아닐 수 있습니다. window.pageYOffset과 window.scrollY 속성값은 같습니다. scrollY는 오래된 브라우저는 지원이 안 되는 경우가 있으므로, pageYOffset이 하위 브라우저 지원까지 안전합니다. 스크롤 위아래 방향 판단하기 스크롤될 수 있도록 높이값을 설정해줘야 합니다. body{ height: 300vh; /* 스크롤될 수 있도록 높이값 설정하기 */..
2022.09.28