전체 글 (84) 썸네일형 리스트형 Python - 입력값 받기 코딩테스트 환경에 다시 익숙해지고자 기본 입출력 문제를 반복했다. [입출력] boj 11718, 11719 - EOF 판단 array vs list 파이썬에서는 리스트가 곧 배열이다. input()은 한 줄을 str 형태로 받는다. 줄바꿈이 포함된 입력을 넣어도 첫 줄만 받아감. 코테에서는 시간 단축을 위해 input 대신 sys.stdin.readline을 많이 쓴다. 줄바꿈까지 받기 때문에 strip이나 map split으로 제거하고 사용함. import sys sys.stdin.readline() sys.stdin.readline으로 여러줄 입력 받기 import sys num = int(input()) arr = [sys.stdin.readline() for i in range(num)] prin.. JS - callback, promise JS 강의 필기 + 추가 JS is synchronous. Execute the code block by order after hoisting callback function을 중첩하면 가독성이 떨어지고 유지 보수가 용이하지 않음 console.log('1'); setTimeout(() => { console.log(2); }, 1000); // 1초 뒤 콜백함수 실행 console.log('3'); // 1 3 2 순으로 출력됨 synchronous callback function printImmediately(sentence){ sentence(); } // 이 부분은 hoisting 됨 printImmediately(() => console.log('hello')); asynchronous call.. JS - JSON JS 강의 필기 + 추가 JSON javascript object notation JSON.stringify object to JSON stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; overloading: 함수의 이름은 같지만 전달하는 param에 따라서 각각 다른 방식으로 호출이 가능 let json= JSON.stringify(true); console.log(json); // tr.. JS - array JS 강의 필기 + 추가 array 자료구조의 일종 array declaration const arr1 = new Array(); const arr2 = [1, 2]; index position python과 달리 -1 index를 줄 수 없다. const fruits = ['a', 'b']; console.log(fruits); // (2) ["a", "b"] console.log(fruits.length); // 2 console.log(fruits[0]); // index에 해당하는 값 나옴 console.log(fruits[2]); // 없는 index 결과: undefined console.log(fruits[fruits.length - 1]); // 마지막 값 looping over an ar.. JS - object JS 강의 필기 + 추가 object { key : value } a collection of related data and/or functionality Nearly all objects in JS are instances of the class Object object 만드는 방식 2가지 const obj1 = {}; // 'object literal' syntax const obj2 = new Object(); // 'object constructor' syntax property 추가하기 const ellie = { name: 'ellie', age: 4 }; // object 생성 ellie.hasJob = true; // property 추가 console.log(ellie.hasJob); /.. 이전 1 ··· 12 13 14 15 16 17 다음 목록 더보기