본문 바로가기

프로그래밍 언어51

ES6 이터러블 /이터레이터, 리스트 순회 리스트 순회 기존 for(var i =0;i< str.length;i++){ ... } es6 for(const a of list){ ... } 간결하게 변경 되었음 이터러블/이터레이터 Array , Set, Map const arr = [1,2,3]; for(const a of arr){ } const set = new Set([1,2,3]); for(const a of set){ } const map = new Map(['a',1], ['b',2] , ['c',3]); for(const a of map){ } array 는 arr[0] , arr[1] 이렇게 해서 값을 찾을 수 있지만 Set과 Map은 불가능함 어떻게 for of문에서 동작이 되는가? Symbol.iterator es6에 추가된 sy.. 2021. 7. 3.
promise / async await promise 자바스크립트 비동기 처리에 사용되는 객체 보통 서버에서 받아온 데이터를 화면에 표시할 때 사용 function getData(callback){ return new Promise(function(resolve,reject)){ axios.post(&#39;~~&#39;, param) .catch(function (err) { }).then(function (rs) { resolve(response); }); } } getData().then(function(data){ console.log(data); });프로미스 상태(states) Pending(대기) : 비동기 로직이 완료 x new Promise(); 메서드 호출 할 때 Fulfilled(이행) : 비동기 처리 완료되어 프로미스가 .. 2021. 6. 29.
vsCode 에서 C++ 실행 및 디버깅 task.json 이거 생성하는 방법은 구글링...하면 다 나와있음....{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "g++ build active file", "command": "/usr/bin/g++", "args": [ "-std=c++17", "-stdlib=libc++", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.out", "&&", "${fileDirname}/${fileBasenameNoExtension}.out", //루트 밑에 sample_input.txt 생성해야한다. "", "${fileDirname}/sample_output.txt" ], .. 2021. 4. 19.
가비지컬렉션 가비지컬렉션이란? C나 C++ 에서는 OS레벨의 메모리에 직접 접근하기 때문에 메모리를 명시적으로 해제해주어야한다. 그렇지 않으면 메모리누수가 생김. 반면 자바는 OS메모리 영역에 직접 접근하지 않고 JVM가상머신을 이용해 간접적으로 접근함 오브젝트가 필요해지지않는 시점에서 알아서 free()를 수행해서 메모리를 확보함. 이런 메모리 관리를 자바 가상머신에게 맡기는것. 가비지컬렉테는 메모리를 안쓰는 놈을 자동 해제시키는데 그럼 내부적으로 메모리를 안쓰는지 어떻게 판단하지? GC는 unreachable object(stack에서 도달할 수 없는 heap영역의 객체) 를 우선적으로 메모리에서 제거하여 메모리 공간확보를 한다. 2020. 12. 4.
반응형