프로그래밍
-
[JS] 자바스크립트 기본 - 코드 구조프로그래밍/JavaScript 2021. 4. 27. 22:14
코드 구조 세미콜론 대부분의 경우, 줄 바꿈이 있으면 자바스크립트는 '암시적' 세미콜론으로 해석하여 세미콜론을 따로 적지 않아도 된다. 하지만 대괄호 [ ]의 앞부분 등 인식하지 못하는 경우도 존재! 그러므로 세미콜론을 사용하는 것이 좋다. 주석 한줄 주석은 // 여러 줄은 /* */ use strict 지시자 기존 기능에 변경된 사항들을 활성화 하는 것 (엄격모드) 호환성 이슈 때문에 활성화 하지 않았던 것들을 활성화 시키는 지시자이다. 맨 상단에 "use strict"; 위치 시킬 것. 또한 일단 엄격모드가 실행되면 되돌릴 수 없다. (클래스와 함수를 사용한다면 이미 use strict가 적용되었기 때문에 따로 명시할 필요가 없다)
-
[node] 노드 기능 알아보기프로그래밍/JavaScript 2021. 3. 2. 21:30
REPL - read, eval, print, loop 모듈 // var.js const odd = '홀수입니다'; const even = '짝수입니다'; module.exports = { // 해당 파일을 모듈로서 사용 가능하게 한다. odd, even, }; // func.js const { odd, even } = require('./var'); // var 파일에서 가져옴 function checkOddOrEven(num) { if(num%2){ return odd; } return even; } module.exports = checkOddOrEven; // index.js const { odd, even } = require('./var'); const checkNumber = require(..
-
[JS] 자바스크립트 기본 문법 정리프로그래밍/JavaScript 2021. 2. 27. 14:59
변수 차이점 var 함수 스코프이기 때문에 블록 안에서 정의했어도 밖에서 사용 가능 const, let 블록 스코프를 가지므로 블록 밖에서는 접근 불가능 코드 관리가 수월해짐 const const는 한번 대입하면 다른 값 대입 불가 let let은 다른 값 재할당 가능 템플릿 문자열 string2 = `${num3} 더하기 ${num4}는 '${result2}'`; # 1 더하기 2는 '3' 객체 리터럴 const es = 'ES' const newObject = { sayJS(){ // sayJS: function()으로 정의할 필요 없이 가능 console.log('JS'); }, sayNode, [es + 6]: 'Fantastic', // 객체 리터럴 안에서 가능 }; console.log(new..
-
[node.js] version 에러프로그래밍/JavaScript 2021. 2. 15. 14:42
theia를 실행시키기 위해 yarn을 실행하면 pty.target.mk:111 : recipe for target 'Release/obj.target/pty/src/unix/pty.o' failed 다음과 같은 에러 발생.. 구글링 해보니 버전 문제라고 해서 v12에서 v10으로 낮추면 > nvm use 10 error p-debounce@3.0.1: The engine "node" is incompatible with this module. Expected version ">=12". Got "10.23.3" 악!!!!!!!!!!!!!!!!!!!
-
[node.js] 노드 시작하기프로그래밍/Node.js 2021. 2. 7. 22:08
서버 서버는 네트워크를 통해 클라이언트에 정보나 서비스를 제공하는 컴퓨터 또는 프로그램 노트는 자바스크립트 애플리케이션이 서버로서 기능하기 위한 도구를 제공하므로 서버 역할. 자바스크립트 런타임 런타임은 특정 언어로 만든 프로그램들을 실행할 수 있는 환경을 의미한다. 이벤트 기반 이벤트가 발생할 때 미리 지정해둔 작업을 수행하는 방식을 의미한다. 이벤트 기반 시스템에서는 특정 이벤트가 발생할 때 무엇을 할 지 미리 등록해 두어야 함 이벤트 리스너에 콜백 함수를 등록한다, (클릭 이벤트 리스너에 경고창을 띄우는 콜백함수 등록) 이벤트 루프 이벤트 발생 시 호출할 콜백 함수들을 관리하고, 호출된 콜백 함수의 실행 순서를 결정하는 역할을 담당한다. 노드가 종료될 때까지 이벤트 처리를 위한 작업을 반복하므로 루..
-
[🛸 Flask] Flask Blueprint프로그래밍/Django & Flask 2021. 1. 16. 15:03
Blueprint 장고는 각 application마다 views를 이용해 실행시킬 함수를 분리시키는게 가능했다. 예를 들어 게시글 application => views (글쓰기, 댓글쓰기, 글삭제 등등) 회원관리 application => views (회원가입, 회원탈퇴 등등) 그런데 플라스크는 main.py 안에서 모든 함수를 작성한다. 그러면 main.py 안에 내용이 매우 길어짐! 그래서 사용하는 것이 blueprint다. #main_views.py from flask import Blueprint bp = Blueprint('main', __name__, url_prefix='/') # 'main'은 장고의 namespace와 같은 용도 # 함수정의 def ~ # __init__.py from ...