Study/JavaScript
-
[코드스테이츠 TIL] Complexity 복잡도Study/JavaScript 2019. 11. 4. 21:26
자료구조 및 배열 sorting 방법에 따라 효과적인 코딩이 가능하다 https://www.bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell Know Thy Complexities! Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting..
-
[코드스테이츠 TIL] Number, Math methodStudy/JavaScript 2019. 11. 4. 15:18
[ Number ] Number.isInteger(value) - arguments : 정수인지, 아닌지 여부를 검사할 값 - return value : 정수를 판단한 결과 (Boolean) Number.isInteger(0); // true Number.isInteger(1); // true Number.isInteger(-100000); // true Number.isInteger("10"); // false Number.isInteger(0.1); // false Number.isInteger(Math.PI); // false parseInt(value) / parseFloat(value) - arguments: 형변환(type casting)하기 위해 파싱될 값 - return value: 정수 ..
-
[코드스테이츠 TIL] 배열 Array methodStudy/JavaScript 2019. 11. 2. 12:15
[ 배열 Array ] 객체지향 대안으로 함수형 프로그래밍을 선호하는 추세인데 array를 공부하는 것이 중요하다. 배열은 객체의 일부이기 때문이다. Array.isArray(obj) : 인자가 배열이라면 true를 반환하고, 아니라면 false를 반환한다. 기본적으로 typeof 를 쓰면 데이터 타입을 알 수 있는데, array는 object 타입으로 나오기 때문에, array 타입인지 구분하려면 Array.isArray() 메소드를 사용해야한다. Array.isArray([1, 2, 3]); // true Array.isArray({foo: 123}); // false 객체와 배열은 strict equal(===)로 구분할 수 없다. 왜냐하면 객체와 배열은 reference type이기 때문이다. c..
-
[코드스테이츠 TIL] 문자열 String method , DebugStudy/JavaScript 2019. 10. 31. 22:42
[ 문자열 String ] 문자열은 index로 접근은 가능하지만 쓸 수는 없다 (read only) let str = 'codestates' str[0] = 'g' //str === 'codestates' 이렇게 했을 경우 변수 str은 godestates가 아니라 codestates 그대로 있다 숫자와 문자열에 '+ 연산자'를 사용할 경우 결과는 문자열로 변환된다 console.log(123 + '456') //'123456' str.indexOf('searchValue') : 찾고자 하는 문자열과 처음으로 일치하는 index를 리턴한다. 일치하는 문자열이 없으면 -1을 반환한다. 'Blue Whale'.indexOf('Blue'); // returns 0 'Blue Whale'.indexOf('Bl..
-
[코드스테이츠 TIL] 자바스크립트 배열, 반복문, 객체와 methodStudy/JavaScript 2019. 10. 10. 16:00
[배열 array] 배열 : 순서가 있는 값 요소 : 배열의 값 element 순서 : 인덱스 index / 0부터 번호를 매긴다 let myNumber = [12, 34, 45, 56] myNumber[0] = 12 배열로 할 수 있는 것들 : property and method 온점(dot . )을 이용해서 변수가 가지고 있는 property에 접근할 수 있다 myNumber.length 온점(dot . )을 이용해서관련된 method를 실행할 수 있다. method는 함수 실행처럼 괄호를 열고 닫는 형태로 실행한다. myNumber.push(98) [반복문 loops and iteration] 반목문 : 반복할 내용과 조건을 코드로 작성 for 구문과 while 구문 차이는 거의 없다 for (le..