입문자를 위한 웹 프론트엔드 2
Document Object Model
Browser Object Model
document.body.append("text");
var p = document.createElement("p");
p.textContent = "text";
document.body.appendChild(p);
document.querySelector("p");
document.querySelectorAll("p");
// package.json
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
https://dontkry.com/posts/comics/roommates.html
var x = 0;const z = 0;let y = 0;function print(string) {
console.log(string);
}
print("hello");
const print = (string) => {
console.log(string);
};
print("hello");
var x = "hello";
function log() {
console.log(x);
}
function main() {
x = "world";
log();
}
var x = "hello";
function log() {
console.log(x);
}
function main() {
var x = "world";
log();
}
callback(function () {
callback(function () {
callback(function () {
callback(function () {
// ...
});
});
});
});
const get = async () => {
const data = await fetch();
const ... = await ...();
};
promise()
.then((data) => {
// ...
})
.then((data) => {
// ...
})
.then((data) => {
// ...
})
.catch((error) => {
// ...
})
.finally(() => {
// ...
});
const array = [];
for (let i = 0; i < 10; i++) {
array.push(i);
}
const array = Array(10).fill(0).map((v, i) => i);
console.log(array);