Position value
static
- default value
relative
- move relatively from static position
absolute
sticky
- class
- const & let
- block scope
- arrow function
- promise
- spread operator
- template literal
${expression}with `- destructuring
let
const
hoisting (변수 할당 전에 접근 시)
- var : undefined
- let :
reference error
지역변수
- 함수 내부에 선언
- 함수 내부에서만 접근 가능
- 함수가 시작될 때 생성되고, 함수 context가 종료될 때 삭제됨
전역변수
- 함수 외부에 선언
- 어디에서나 접근 가능
{} 가 있는 경우
var a
전역 변수
var b
지역 변수
function scope
varvariables are function scope.: It means they are only available inside the function they’re created in, or if not created inside a function, they are ‘globally scoped.’
globally scoped: returns
undefined
let c
선언 과 할당 으로 구분됨1 | function hoisting() { |
1 | var g = "web"; |
1 typeof == object
- Boolean
- Number
- BigInt
- String
- ``
내부에${}` 변수 사용 가능- Symbol
- 유일한 식별자
- 내용이 같아도 변수가 다르면 다른 객체임
- Null
- 값이 존재하지 않음
- 값을 알 수 없음
1 typeof == undefined
- Undefined
- 값이 할당되지 않음
1 | const arr; |
undefined 로 처리된다새로운 배열 반환사전 기준 으로 순서대로 나열새로운 배열 반환JavaScript method
- 반복문
![]()
for ... in
- index 접근
for ... of
- element 접근
forEach
- index, element 모두 접근
(element, index)순서 바꾸면 안 됨!
- String 반복
1
2 // String의 `repeat` 함수
String.repeat(i)
일급 객체() 를 이용하여 함수를 호출하지 않으면 실행되지 않음사용하는 이유
- 코드 재사용
- 같은 함수에 다른 인자를 넣으면 다른 결과를 냄
함수 선언문
기명함수 표현식
_name 형식잘 사용하지 않음
익명함수 표현식
가장 많이 사용!
undefined 반환return undefined; 와 동일좋은 함수 만들기
- 하나의 함수는 하나의 기능만
- 함수명은 짧고 명확해야 하며, 동사로 시작
- lowerCamelCase
- arrow function으로 작성하는 것이 권장됨
주로
===이용할 것!
**property === (key , value) ** 쌍 1개
key: value,value에는 어떤 것이든 올 수 있음
property 간에는 쉼표로 구분됨
method : property value로 함수가 오는 것
varName.methodName() 으로 호출sayHi method객체 표현식
(key, value) 로 구성된 property들의 정렬되지 않은 집합
서버-클라이언트 통신할 때 사용함
localStorage 등 웹 저장소에 저장할 때도 사용함
localStorage data is specific to the protocol of the document
In particular, for a site loaded over HTTP (e.g.,
http://example.com),localStoragereturns a different object thanlocalStoragefor the corresponding site loaded over HTTPS (e.g.,https://example.com).
JavaScript
synchronous
Synchronousmeans that if you need to wait for something, then everything stops until the wait is over.single thread
Single threadedmeans that only one thing happens at a time.
Sync
1 | const getCoffee = (coffee) => { // coffee === null |
Async
1 | const getCoffee = (coffee) => { // coffee === null |
single thread 이기 때문에 효율성을 위해서 기본적으로 동기적 으로 처리함콜백 함수를 이용함setTimeout
Asynchronous : setTimeout()에 모두 묶어버림
callback function : const second
콜백 지옥
- 클린 코드를 위해 피해야 할 것!
- if문 분기와 error handling을 어렵게 만듦
익명함수를 분리하여
기명함수로 작성하거나
promise와 같은 비동기 처리를 사용할 것
자바스크립트 비동기 처리에 사용되는 객체
new Promise() 를 통해 선언, 인자는 (resolve, reject)
const promise = new Promise((res, rej) => {});return 값은 resolve나 reject 내부의 메시지
resolve, reject 둘 중 하나만 실행
fetch 를 사용하여 실제 API를 호출하면 Promise 객체가 반환됨
response.json() 을 통해 response의 body를 JSON 객체로 변환함
then 실행throw Error() 를 통해 에러가 발생하면 catch 실행catch 실행
finally는 결과 상관 없이 실행됨
then, catch 를 사용하지 않고 무조건 Promise 결과를 얻음Alert : 사용자가 확인을 누를 때까지 메시지를 보여줌
Prompt : 사용자에게 값을 입력받음
첫번째 인자는 notifying message
두번째 인자는 default 값, 사용자가 취소를 누르면 null 리턴
Confirm : 사용자에게 질문을 보여주고 true / false 리턴
API이기 때문에 자바스크립트로 조작한다1 | <!- 넓이와 높이 지정해야 함 (css로 조정해도 됨) -> |
1 | // canvas element 가져오기 |
1 | <div class="bucket"> |
id 지정 후 draggable="true"1 | #cat { |
z-index 설정1 | const buckets = document.querySelectorAll(".bucket"); |
1 | function allowDrop(event) { |
1 | /* |
1 | /* |
Always Design for Mobile First

데스크탑, 태블릿, 노트북, 스마트폰 등의 다양한 기기가 등장하면서 데스크탑의 화면에 최적화되어 있던 레이아웃을 각 기기의 화면 크기에 맞게 유동적으로 변동해야 하는 필요성이 대두됨내용은 동일하지만 최적화된 레이아웃 렌더링모바일 시장
더 나은 User eXperience
빠른 페이지 로딩 속도
효율적이고 cost-effective
media query 이용해 breakpoint 적용px 으로 표현됨em 또는 % 으로 표현됨responsive 과 fluid 레이아웃의 결합
media query 의 breakpoints 이용
더 자연스러운 레이아웃 변화
@media rule| Value | Description |
|---|---|
| all | Default. Used for all media type devices |
| Used for printers | |
| screen | Used for computer screens, tablets, smart-phones etc. |
| speech | Used for screenreaders that “reads” the page out loud |
| Value | Description |
|---|---|
| max-height | The maximum height of the display area, such as a browser window |
| min-width | The minimum width of the display area, such as a browser window |
css
1 | @media not|only mediatype and (mediafeature and|or|not mediafeature) { |
scss
1 | // Media Query Mixins |
html
1 | <link rel="stylesheet" media="screen and (min-width: 900px)" href="widescreen.css"> |


1 | /* Smartphones (portrait and landscape) ----------- */ |
https://css-tricks.com/a-complete-guide-to-css-media-queries/
Getter and Setter
JS는 인터페이스 / 타입 / 접근제어자 (Access Modifier) 을 가지고 있지 않음
Object property를 가져오는 것 이상 (e.g., modify) 의 action을 하고 싶을 때, 일일이 접근제어자를 불러 action을 취하지 않아도 됨
set action 시 validation을 추가하는 것이 좋음
internal representation을 encapsulating
get, set시 logging이나 error handling을 추가하는 것이 용이함
get 시 lazy load 속성을 추가할 수 있음
Lazy loading
- It’s a way to shorten the length of the critical rendering path, which translates into reduced page load times
- getting the properties from a server
- identify resources as non-blocking (non-critical)
- load these only when needed
1 | // bad |
objects의 properties는 private로 만들기
closures1 | // bad |
함수 parameter / argument는 2개 이하
함수 테스팅을 쉽게 만들어 주기 때문
3개 이상인 경우: 통합하기
higher-level object의 경우 1개로 충분함
객체를 생성하고 활용하기
boilerplate: 변경 없이 계속 재사용할 수 있는 코드, 프로그램
Destructuring
구조 분해 할당 구문은 배열이나 객체의 속성을 해체하여 그 값을 개별 변수에 담을 수 있게 하는 JavaScript 표현식입니다.
function signature (argument, return type) 등을 통해 어떤 값이 전달되고 이용되는지 알 수 있음named parametersnamed parameters : function calls that clearly state the name of each parameter within the function call
전달된 argument에 default 값을 복제함, argument로부터 destructure된 object / array는 복제되지 않음1 | // bad |
하나의 함수는 하나의 행동만
1 | // bad |
1 | // bad |
❓(2)와 어떤 차이가 있는지?
1 | // bad |
중복된 코드는 삭제하기
비슷한 일을 하는 함수들이 사소한 차이로 개별적으로 존재하는 경우
👉 추상화 를 통해 하나의 함수/ 모듈/ 클래스를 사용하여 사소한 차이점을 (argument 등으로) 다루기 : 한 곳만 수정해도 다른 코드에 반영할 수 있음
e.g. JAVA의 class
1 | // bad |
Object.assign 으로 default object 만들기
1 | // bad |
flags 는 그 자체로 하나 이상의 기능을 하는 것을 의미하므로, 단일 기능을 하는 함수로 나누기!플래그(flags)
정규 표현식을 생성할 때 플래그를 사용하여 기본 검색 설정을 변경할 수 있습니다.
이렇게 설정된 플래그는 나중에 추가되거나 삭제될 수 없습니다.
플래그(flag) 설명 i 검색 패턴을 비교할 때 대소문자를 구분하지 않도록 설정함. g 검색 패턴을 비교할 때 일치하는 모든 부분을 선택하도록 설정함. m 검색 패턴을 비교할 때 여러 줄의 입력 문자열을 그 상태 그대로 여러 줄로 비교하도록 설정함. y 대상 문자열의 현재 위치부터 비교를 시작하도록 설정함.
1 | // bad |
Side Effect
함수가
take a value in and return another value / values외의 action을 할 경우 side effect가 발생함e.g. writing to a file, modifying some global variable, etc.
centralize where you are doing this (하나의 함수로 통일할 것!)TypeScript 이용하기, not centralizing where your side effects occur1 | // bad |
cloningclone - edit - return 하기1 | // bad |
global function 사용하지 않기
👉 inheritance 이용하기!
1 | // bad |
imperative 보다 favor(functional) programming 하기
Imperative programming : writing your program as a series of instructions (statements) that can actively modify memory (variables, arrays)
- focuses on how : express the logic of your program based on how the computer would execute it
Functional programming : writing your program in terms of functions and other mathematical structures
- A function is just a rule that maps input elements to output
- concentrates on the what : trying to let you specify the logic of your program as close to actual logic as possible
- more expressive : writing less code
- safer : more bugs are prevented by the language ahead of time
- side-effects are controlled
1 | const programmerOutput = [ |
Encapsulation
bundling data and methods that work on that data within one unit
- hide the internal representation, or state, of an object from the outside
- e.g., a class in Java
1 | // bad |
1 | // bad |
👉 각 case에 해당되는 함수 개별적으로 만들기
1 | // bad |
consistent APIs
1 | // bad |
TypeScript
1 | // bad |
over-optimising 피하기
1 | // bad |
Dead Code 지우기
1 | // bad |
변수 이름
의미 있는
발음하기 쉬운
1 | // bad |
1 | // bad |
1 | // bad |
1 | const address = 'One Infinite Loop, Cupertino 95014'; |
1 | const locations = ['서울', '인천', '수원']; |
1 | // bad |
undefined 일 때 적용됨falsy 값 포함) 은 적용되지 않음1 | // bad |
pull request 을 이용하여 자동으로 merge되는 것을 방지함
1 | git init <folder name> |
git
new Repository 생성
1 | git remote add origin <address> |
update
1 | git add . |
1 | git log // log 확인 |
1 | git push origin master // 원격 저장소 master 브랜치 업데이트 |
http://sopt.org:80/wphttp://sopt.org:80/wp/url.pdfhttp://sopt.org:80/wp/?page_od=2519
httpdomain name
sopt.orgport
80path
wpquery
?page_id=2519IP
HTTP
request
reponse
HyperText Markup Language
웹 페이지의 뼈대를 담당한다.
HyperText
Markup Language
<!DOCTYPE html>명시- semantic tag 지원
- form 기능 개선
- 다양한 API 지원
1 | <tag attribute="value"> ...content... </tag> |
태그 이름은 대소문자 구분이 없다
태그가 엇갈려서 중첩되면 안 된다
여러 속성이 tag에 들어갈 수 있음
content
<단독 태그 />
<html>
<!DOCTYPE html> 을 벗어날 수 없음<head>
<meta><style><body>
iframe 은 보안 문제가 있으므로 embed 이용하기<div> 로 블록 요소를 그룹화<span> 으로 인라인 요소를 그룹화
CSS3
- 웹 문서용
- 모듈 기반
- 원하는 모듈만 탑재 가능
- 필요한 모듈만 빠르게 업데이트 가능
- 기존의 도구 없이도 화려하고 동적인 스타일 구현 가능
1 | <tag style="color: red;"> ...content... </tag> |
tag 별로 style 첨부
<head> 안에 style 첨부
외부 css 파일 import
1 | <link rel="stylesheet" type="text/css" href="*.css"> |
<head> 의 <style><link>로 연결된 css 파일늦게 선언된 스타일을 우선 적용
*#., 로 구분; 로 구분, 로 나열선택자 사이의 띄어쓰기: 선택자 조합
h3 p {...}
선택자 사이의 > : 자식 선택자
h3 > p {...}
text-transform
position
overflow
box-sizing
0 1 auto1 0 autoreact component = view
identity reducer
👇but normally uses hooks👇
※ for React
react-query.tanstack.com/reference/useQuery
useQuery
Subscribe to our newsletter The latest TanStack news, articles, and resources, sent to your inbox.
react-query.tanstack.com
useReducer
ko.reactjs.org/docs/hooks-reference.html
Hooks API Reference – React
A JavaScript library for building user interfaces
ko.reactjs.org
🚀 redux devTools
Do one thing -> make sure it is working -> move on to next one
big loop
👇simplified
※ Single component as a single responsibility
프레젠테이션 컴포넌트 (Presentational Component)
프레젠테이션 컴포넌트(Presentational Component) 는 아래와 같은 성질을 갖는다.
● 어떻게 보여지는 지를 책임진다.
컨테이너 컴포넌트 (Container Component)
컨테이너 컴포넌트(Container Component) 는 아래와 같은 성질을 갖는다.
● 어떻게 동작해야 할지를 책임진다.
HTTP/1.1
Base64 Decode and Encode - Online
www.base64decode.org
Autehntication based on username and password
concatenation with :
clinet: React, Angular …
https://jwt.io
[algorithm & token type]header-[data: that needs to be secured]payload(userId, iat)-[verifying key]verify signature: no one can change the content
signature => only if I have a secret, generates the signature / if input is different, signature will be different too
session store: mongodb, file, etc…
npm express-session
npm helmet