웹구현시? 웹언어도 코드를 작성하며 개선을 하는 부분이 있다는 것은 같다. 중복되는 부분은 줄이고, 보다 직관적으로 유지보수하기 유리하게 코드를 작성하는 것이 필요하다.
자바스크립트? 스크립트언어란 컴파일하지 않고 실행하는 프로그래밍 언어를 말한다.
var - 지변, 전역화 되어서 처리됨 → 호이스팅이슈 있음.
const - 상수선언 시 사용(ES6), 재정의 x
let - 변수, 재정의 o
const content = document.createElement('div');
const title = document.createElement('h1');
content.appendChild(title);
------- ------
//h1을 품은 div 생성
//<div><h1>제목{텍스트노드 : 태그 이름 없고 값 있음.}</h1></div>
GD@GD MINGW64 /d/vscode_web/news_step1
$ **npm install -g parcel -bundler**
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
added 195 packages in 9s
85 packages are looking for funding
run `npm fund` for details
GD@GD MINGW64 /d/vscode_web/news_step1
$ **npm init -y**
Wrote to D:\vscode_web\news_step1\package.json:
{
"name": "news_step1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
GD@GD MINGW64 /d/vscode_web/news_step1
$ **parcel index.html**
Server running at http://localhost:1234
✨ Built in 7ms
const TITLE_URL = 'https://api.hnpwa.com/v0/news/1.json';
const CONTENT_URL = 'https://api.hnpwa.com/v0/item/@id.json';
JSON.parse(text) //text = JSON으로 반환할 문자열
해커뉴스가 응답으로 JSON 포맷으로 데이터셋을 줌
JSON → Array 변경(JSON.parse(ajax.response))
function 함수명(){ return}
const ncontent = getData(CONTENT_URL.replace('@id', id));
// const ncontent = JSON.parse(ajax.response);
// ajax.open('GET', CONTENT_URL.replace('@id', id), false);
// ajax.send();
function getData(url) {
ajax.open('GET', url, false);
ajax.send(); //서버측에 요청 보내고 응답 기다리는 중
return JSON.parse(response);
}
getData = (url) => {
ajax.open('GET', url, false);
ajax.send(); //send()호출될 때 비로서 서버측에 요청이 일어남
return JSON.parse(ajax.response);
};
relative
absolute
//::after 를 이용해서 clear: both;
.wrap ::after {
content: "";
display: block;
/* 밀려나는 것을 방지한다 */
clear: both;
}
clear: both; 오른쪽/왼쪽을 취소, 가장 많이 사용
clear: left; 왼쪽을 취소
clear: right; 오른쪽을 취소
clear: none; 기초값을 clear값을 설정하지 않은 것과 같다