본문 바로가기

전체 글

[JS] forEach, map, filter forEach const arr = [1,2,3,4]; const newArr = arr.forEach((e)=>{ return e; }); console.log(newArr); // undefined forEach 를 출력해보면 undefined 가 나온다. return 값이 별도로 존재하지 않는다. map const arr = [1,2,3,4]; const newArr = arr.map((e)=>{ return e * 2; }); console.log(newArr); // [ 2, 4, 6, 8 ] const emails = [ 'sherlock@gmail.com', 'mina@namver.com', 'lily@daum.net', 'ivy@nate.com', 'jay@gmail.com' ]; cons.. 더보기
className className Click Box className classList add remove class toggle 더보기
prettier html 적용 끄기(mac vscode) vscode 1. command + , 2. prettier 입력 후 settings 탭으로 간다. 3. disable language 에서 html 을 추가해 준다. 더보기
closure, callback 예시 만들기 클로저란? 함수가 종료되어도 지역변수가 사라지지 않고 활용되는 것. -출처: 모던 웹을 위한 JavaScript jQuery 입문 책을 보고 예시를 만들어 보았다. 콜백(callback) 예시. 콜백이란, 매개변수에 인자로 함수가 전달되는 것. 더보기
생활코딩 자바스크립트 class 강의를 보고 만든 예제 class Students { constructor (name, scoreA, scoreB) { this.name = name; this.scoreA = scoreA; this.scoreB = scoreB; } sum () { return (this.scoreA + this.scoreB); } info () { return `name: ${this.name}, total: ${this.sum()}`; } } var stu001 = new Students('mina', 100, 70); var stu002 = new Students('lily', 90, 60); console.log(stu001); // Students { name: 'mina', scoreA: 100, scoreB: 70 } consol.. 더보기
생활코딩 자바스크립트 this, prototype 강의를 보고 만든 예제 var student001 = { name: 'sherlock', scoreA: 90, scoreB: 80, scoreSum: scoreSum }; var student002 = { name: 'lily', scoreA: 80, scoreB: 70, scoreSum: scoreSum }; function scoreSum () { return `name: ${this.name}, total: ${this.scoreA + this.scoreB}`; } console.log(student001.scoreSum()); console.log(student002.scoreSum()); 생활코딩 this 강의를 보고 예제를 만들어 보았다. https://www.opentutorials.org/module/4047/2.. 더보기
Mac os brew 이용 nodejs 설치하기 brew 를 설치한 김에 nodejs 도 설치할 수 있는 지 구글링을 하니 역시 가능하다. brew가 설치되어 있는 환경에서 $ brew install node 라고 명령어를 입력하면 된다. 설치 후에 node -v npm -v 를 통해 버전을 확인할 수 있다. 현재 node 12는 lts 버전이 아니므로 최신 lts 버전으로 변경하고 싶었다. 참고한 블로그 주인께서 해당 내용도 작성해 주셔서 내용을 보고 변경하였다. $ sudo npm install -g n $ sudo n lts 위 코드를 입력하면 최신 lts 10 버전으로 변경된다. 자세한 내용은 아래 블로그에서 확인해보자. 참고: https://deok.me/entry/n-%EC%9D%84-%ED%86%B5%ED%95%98%EC%97%AC-Nod.. 더보기
Mac os, python3, miniconda 설치 맥북에어를 새로 사서 파이썬3를 새로 설치가 필요했다. (맥에는 기본적으로 파이썬2가 설치되어 있다.) 파이썬3를 설치하고 가상환경을 사용하는 방법은 여러가지가 있다. https://github.com/ahastudio/til/blob/master/python/20181214-setup-python-project.md ahastudio/til Today I Learned. Contribute to ahastudio/til development by creating an account on GitHub. github.com (아샬님의 파이썬 프로젝트 시작하기를 참고하면 된다!) 여기서는 mac os 환경에서 brew 와 miniconda를 이용하기로 한다. https://brew.sh/index_ko /u.. 더보기