JavaScript에 대해서 교육을 받았다.
넓은 의미로 웹 브라우저가 HTML로 만들어진 페이지를 인식하는 방식을 의미한다.
문서 객체가 생성되는 방식
- 정적으로 문서 객체를 생성 : 웹 브라우저가 HTML 페이지에 적혀 있는 태그를 읽으면서 생성하는 것.
- 동적으로 문서 객체를 생성 : 원래 HTML 페이지에 없었던 문서객체를 JavaScript를 이용해서 생성
자바스크립트는 웹페이지에 생동감을 불어넣기 위해 만들어진 프로그래밍 언어이다.
자바스크립트로 작성한 프로그램을 스크립트(script) 라고 부른다.
함수를 호출할 때 생성되는 실행 컨텍스트 객체이다.
this가 가리키는 대상은 어떻게 this가 호출되는지에 따라 다르다.
아래 상황별로 this의 의미를 나눌 수 있다.
- 전역 공간에서의 this
- 메서드로서 호출할 때 내부에서의 this
- 함수로서 호출할 때 내부에서의 this
- 콜백 함수 호출 시 내부에서의 this
- 생성자 함수 내부에서의 this
예시 )
var obj = {
methodA: function () {
console.log(this)
},
inner: {
methodB: function () {
console.log(this)
}
}
}
console.log(this) // window임 {alert: f(), atob: f(), blur: f(), ...}
obj.methodA() // { methodA: f, inner: {...} } === obj
obj['methodA']() // { methodA: f, inner: {...} } === obj
obj.inner.methodB() // { methodB: f } === obj.inner
obj.inner['methodB']() // { methodB: f } === obj.inner
obj['inner'].methodB() // { methodB: f } === obj.inner
obj['inner']['methodB']() // { methodB: f } === obj.inner
특정 코드를 하나의 명령으로 실행 할 수 있게 해주는 기능
❌ 화살표 함수를 쓰면 안되는 경우
- 객체 메소드
- 생성자 함수
- addEventListener() 의 콜백 함수 -> 써도 상관은 없지만 this를 사용 시 스코프가 window를 잡게 된다.
관련된 데이터와 함수의 집합
ES6에 새로 추가 됨.
짧고 보기 좋게 코드를 작성하기에 좋다.
- (구) 세이프홈즈 : 미디어 쿼리 이용해 반응형으로 만들기.
HTML은 기존 과제로 제출했던 코드에 class만 부여했다.
/* 테블릿 가로, 테블릿 세로 (해상도 768px ~ 1023px)*/
@media screen and (min-width: 768px) and (max-width: 1023px) {
.section_title img {
width: 70%;
}
.section_content_wrap {
width: 70% !important;
}
.section_content2_wrap {
width: 70% !important;
}
.section_content3 {
width: 860px !important;
}
.section_content4_wrap {
width: 70% !important;
}
}
/* 모바일 가로, 모바일 세로 (해상도 480px ~ 767px)*/
@media screen and (max-width: 767px) {
.section_title img {
width: 60%;
}
.section_content_wrap {
width: 40% !important;
justify-content: center !important;
}
.section_content2_wrap {
width: 40% !important;
}
.section_content2 strong {
height: 60px !important;
margin: 5px 0;
}
.section_content2 {
width: 165px !important;
}
.section_content3 {
width: 500px !important;
height: 480px !important;
}
.section_content3_wrap {
height: 80% !important;
}
.section_content3_info strong {
width: 200px !important;
height: 120px !important;
font-size: 27px !important;
line-height: 40px !important;
}
.section_content3_info p {
width: 300px !important;
font-weight: 500 !important;
font-size: 18px !important;
line-height: 28px !important;
color: #6b7684 !important;
}
.section_content3_info {
justify-content: start !important;
}
.message {
height: 76px !important;
width: 300px !important;
}
.message strong {
font-size: 12px !important;
line-height: 17px !important;
}
.message p {
font-size: 10px !important;
line-height: 13px !important;
}
.message_info_wrap {
margin-bottom: 2px !important;
}
.section_wrap .section_content3:last-child .section_content3_info {
height: 200px !important;
}
.section_content4_wrap {
width: 40% !important;
justify-content: center !important;
}
.app_img {
height: 400px !important;
}
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
overflow-x: hidden;
}
header {
width: 100%;
height: 70px;
}
main {
width: 100%;
}
.header_wrap {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
height: 70px;
}
main header {
width: 100%;
height: 768px;
background-image: url("./img/haeder.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin-bottom: 50px;
}
.main_header {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;
position: relative;
width: 100%;
}
.main_header::before {
content: "";
opacity: 0.7;
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
background-color: #000;
}
... 내용 생략
미디어 쿼리를 이용해 반응형으로 디자인 해보았다.
이번 수업을 들으면서 Javascript로 DOM 조작하는 실력을 좀 더 높인 것 같다. 또한 과제를 하면서 미디어 쿼리를 숙달하게 되었고, flex 로 레이아웃 짜는 속도가 예전보다 좀 더 빨라진 것 같아서 뿌듯하다.
본 후기는 유데미-스나이퍼팩토리 10주 완성 프로젝트캠프 학습 일지 후기로 작성 되었습니다.