์๋ ํ์ธ์ ๋ถ์คํฐ์ฝ์ค 3๊ธฐ ์ํฌํฐ์ฆ ํ๋ธ์ ๋๋ค. ๐ฟ
๋ถ์คํฐ์ฝ์ค๋?
์ปค๋ฅํธ์ฌ๋จ์ ๋ค์ด๋ฒ๊ฐ ์ค๋ฆฝํ ๋น์๋ฆฌ ๊ต์ก ์ฌ๋จ์
๋๋ค.
์ํํธ์จ์ด ๊ฐ๋ฐ์ ์์ฑ ๊ต์ก ํ๋ก๊ทธ๋จ, ๋ถ์คํธ์ฝ์ค์ ํจ๊ป
๋น์ ์ ๊ฐ๋ฐ ์ปค๋ฆฌ์ด๋ฅผ ์
๊ทธ๋ ์ด๋ํ์ธ์!
์ ํฌ์คํ ์ ๊ฐ์ ๋ด ์๊ฐํด๋ณด๊ธฐ์ ์์ ์์ ๋ค๋ฃจ๋ ์ฝ๋๋ฅผ ์ง์ ํฌ๋กฌํ๋ฉด์์ ํ์ธ ํด๋ณผ ์ ์๋๋ก ์งํํฉ๋๋ค. ๊ด๋ จ๋ ๊ฐ๋ ๊ณผ ๊ฐ์๋ ํจ๊ป ์ฌ๋ ค๋๋ฆฌ๋ ๋งํฌ์์ ํ์ธํด๋ณด์ค ์ ์์ต๋๋ค.
www.boostcourse.org/cs124/joinLectures/52258
์๋ฐ์คํฌ๋ฆฝํธ์ ์์
๋ถ์คํธ์ฝ์ค ๋ฌด๋ฃ ๊ฐ์
www.boostcourse.org
๊ฐ์ฒด ์๊ณ
https://www.boostcourse.org/cs124/lecture/194638
์๋ฐ์คํฌ๋ฆฝํธ์ ์์
๋ถ์คํธ์ฝ์ค ๋ฌด๋ฃ ๊ฐ์
www.boostcourse.org
์ฐ๋ฆฌ๋ ์ฝ๋์ ์ ๋ฆฌ์ ๋์ ์ํด์ ํจ์๋ผ๋ ๊ฐ๋ ์ ์ฌ์ฉํ์ต๋๋ค. ๊ฐ์ฒด ๋ํ ์ด๋ฌํ ๋ชฉ์ ์ ๊ฐ์ง๊ณ ์ฌ์ฉ๋๋ ๋ฐฉ๋ฒ์ ๋๋ค. ๊ฐ์ฒด๋ ํจ์์ ๊ธฐ๋ฐ ์์์ ์กด์ฌํ๋ ๊ฐ๋ ์ ๋๋ค. ์๋ก ์ฐ๊ด๋ ํจ์์ ๋ณ์๊ฐ ์์ฃผ ๋ง์์ง๋ฉด ์ด๋ฅผ ์ ๋ฆฌํ๊ธฐ ์ํด์ ์ฌ์ฉํ๋ ๊ฒ์ด์ฃ .
๋จผ์ ์ด์ ๊น์ง ํ๋ ์ฝ๋๋ค์ ๋ค์ ์ดํด๋ด ์๋ค. ์ด์ ์ ๋ฐฐ์ด๊ณผ ๋ฐ๋ณต๋ฌธ์ ํ์ฉํด์ ํ์ดํผ๋งํฌ์ ์๊น์ ๋ฐ๊พธ์ด์ฃผ๋ ์ฝ๋๋ฅผ ์ผ์์ต๋๋ค. ์ด ๋ถ๋ถ์ ํจ์๋ก ๋ง๋ค์ด๋ด ์๋ค.
function LinksSetColor(color){
var alist = document.querySelectorAll('a');
var i = 0;
while(i < alist.length) {
alist[i].style.color = color;
i = i + 1;
}
}
๊ทธ๋ฌ๋ฉด ์ด์ ํ์ดํผ๋งํฌ์ ์๊น์ ๋ฐ๊พธ์ด์ผ ํ๋ ๋ถ๋ถ์์ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์๊ฒ ์ฃ .
setColor("powderblue");
๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๋ฐฐ๊ฒฝ๊ณผ ๊ธ์์ ์์ ๋ฐ๊พธ๋ ์ฝ๋๋ ๋ฐ๋ก ํจ์๋ก ๋ง๋ค์ด ๋ด ์๋ค. ์ด ๋ ํจ์ ์ด๋ฆ์ด ๊ฒน์น์ง ์๋๋ก ํ๋๋ฐ ์ฃผ์ํ์ธ์.
function BodySetColor(color){
document.querySelector('body').style.color = color;
}
function BodySetBackgroundColor(color){
document.querySelector('body').style.backgroundColor = color;
}
์ด๋ ๊ฒ ๋ค์ํ ํจ์๋ค์ด ์กด์ฌํ๋ ์ํฉ์์ ์ฐ๋ฆฌ๋ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด ํจ์์ ์ข ๋ฅ๊ฐ ์์ฃผ ๋ง์์ง๊ฒ ๋๋ฉด ์ด ํจ์๋ค๋ผ๋ฆฌ ์ด๋ฆ์ด ์ค๋ณต๋์ง ์๋๋ก ๋ง๋ค๊ฒ ํ๊ธฐ ์ํด์ ๊ต์ฅํ ๋ณต์กํ ์ด๋ฆ์ ์ฌ์ฉํด์ผ ํ๊ฒ ์ฃ .
์ด ๋ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ฉด ์ด ํจ์๋ค์ ๋น์ทํ ๊ฒ๋ค๋ผ๋ฆฌ ๊ทธ๋ฃน์ผ๋ก ๋ง๋ค์ด ๋ฌถ์ด์ค ์ ์์ต๋๋ค. ๋ง์น ์ฌ๋ฌ๋ถ์ ์ปดํจํฐ์์ ํด๋๋ฅผ ๋ง๋ค์ด์ ์ ๋ฆฌํ๋ ๊ฒ๊ณผ ๋น์ทํ ์ํฉ์ ๋๋ค. ์ด๋ ๊ฒ ๋๋ ํจ์๋ค์ ์๋ก ๋ค๋ฅธ ๊ทธ๋ฃน๋ผ๋ฆฌ๋ ์ด๋ฆ์ด ๊ฒน์ณ๋ ๊ด์ฐฎ์ต๋๋ค.
์ฐ๋ฆฌ๋ Javascript์์ ์ด๋ฏธ ์ด๋ฌํ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํด๋ณธ ๊ฒฝํ์ด ์์ต๋๋ค. ๋ฐ๋ก ์๋ ์ฝ๋์์์ฃ .
document.querySelector('body');
์ฌ๊ธฐ์์ document๊ฐ ๋ฐ๋ก ๊ฐ์ฒด์ด๊ณ , querySelector๊ฐ document๋ผ๋ ๊ฐ์ฒด์ ์ํด ์๋ ํจ์๋ผ๊ณ ์๊ฐํ ์ ์๋ ๊ฒ์ ๋๋ค. ์ด๋ ๊ฒ ๊ฐ์ฒด์ ์ํด ์๋ ํจ์๋ค์ ๋ฉ์๋(Method)๋ผ๋ ๋ณ๋์ ์ด๋ฆ์ผ๋ก ๋ถ๋ฅด๊ฒ ๋ฉ๋๋ค.
๊ทธ๋ ๋ค๋ฉด ์๋์ ์ฝ๋์ ๊ฐ์ด ์์ฑ์ ํ ์ ์๊ฒ ์ต๋๋ค.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WEB1 - javaScript</title>
<script>
function LinksSetColor(color) {
var alist = document.querySelectorAll('a')
var i = 1;
while (i < alist.length) {
alist[i].style.color = color;
i++;
}
}
function BodySetColor(color) {
document.querySelector('body').style.color = color;
}
function BodySetBackgroundColor(color) {
document.querySelector('body').style.backgroundColor = color;
}
function nightDayHandler(self) {
var target = document.querySelector('body');
if (self.value === 'night') { //night ๋ชจ๋
BodySetColor('white'); //font
BodySetBackgroundColor('black');
LinksSetColor('powderblue');
self.value = 'day'
}
else { //day ๋ชจ๋
BodySetColor('black'); //font
BodySetBackgroundColor('white');
LinksSetColor('blue');
self.value = 'night'
}
}
</script>
</head>
<body style="">
<a href="WEB.html" style="font-size: 30px;">WEB</a><br>
<input type="button" value="night" onclick="
nightDayHandler(this);
">
<ol>
<li><a href="1.html">HTML</a></li>
<li><a href="2.html">CSS</a></li>
<li><a href="3.html">JAVASCRIPT</a></li>
</ol>
<h2>JavaScript</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente officia incidunt quas reprehenderit alias
eveniet necessitatibus eligendi harum obcaecati temporibus, odit, dolor nulla adipisci tempore illum suscipit
quod voluptatibus debitis quam atque nemo accusantium voluptatum voluptates voluptas. Laudantium labore,
praesentium architecto perspiciatis enim totam! Magni fugit corporis iste ratione dolorem temporibus. Magni
perferendis aspernatur mollitia! Eaque dolorem, exercitationem corrupti amet aliquid quis ab eligendi. Nam odio
maxime quae explicabo repellat velit error fuga dolores quo quia. Quidem beatae iusto dolore eos, consequatur
fuga magnam! Sed esse asperiores dolor et adipisci corrupti eveniet tempore deleniti rerum possimus natus,
reiciendis accusantium ut reprehenderit! Animi quaerat ratione, facere saepe iusto eos, obcaecati, provident
ius doloribus nam! Modi, hic! Est vel ipsam laborum placeat! Non nulla dolorum autem corrupti.
</p>
<input type="button" value="night" onclick="
if(this.value === 'night'){
document.querySelector('body').style.backgroundColor = 'black';
document.querySelector('body').style.color = 'white';
this.value = 'day'
}
else{
document.querySelector('body').style.backgroundColor = 'white';
document.querySelector('body').style.color = 'black';
this.value = 'night'
}
">
</body>
</html>
์๊ฐํด๋ณด๊ธฐ
1) ๋ค์ ์ฝ๋์์ ๊ฐ์ฒด์ ๋ฉ์๋๋ฅผ ์ฐพ์๋ณด์ธ์.
var fruits = ["apple", "banana"];
fruits.push("coconut");
์ฌ๊ธฐ์์ ๊ฐ์ฒด๋ fruits๊ฐ ๋๊ฒ ๊ณ ๋ฉ์๋๋ push() ๊ฐ ๋๊ฒ ๋ค์.
๊ฐ์ฒด(์ฐ๊ธฐ์ ์ฝ๊ธฐ)
https://www.boostcourse.org/cs124/lecture/194639/
์๋ฐ์คํฌ๋ฆฝํธ์ ์์
๋ถ์คํธ์ฝ์ค ๋ฌด๋ฃ ๊ฐ์
www.boostcourse.org
๊ฐ์ฒด์ ์ฝ๊ธฐ์ ์ฐ๊ธฐ
์ฐ๋ฆฌ๋ ์ด์ ์ ๋ฐฐ์ด์ ๋ํด์ ๋ฐฐ์ด ์ ์ด ์์์ต๋๋ค. ์ด๋ค ๊ฐ๋ค์ ์์๋ฅผ ๊ฐ์ง๋๋ก ์ ์ฅํ๋ ๊ตฌ์กฐ์์ต๋๋ค. ๊ทธ๋ ๋ค๋ฉด ์์ ์์ด ์ ์ฅํ๋ ๊ตฌ์กฐ๋ ์์ด์ผ๊ฒ ์ฃ ? ๊ทธ๊ฒ์ด ๋ฐ๋ก ๊ฐ์ฒด์ ๋๋ค.
๊ฐ์ฒด์๋ ์์๊ฐ ์๋ ๋์ ๊ฐ๊ฐ์ ์ด๋ฆ์ด ๋ถ์ด ์์ต๋๋ค. ์ด๋ฆ์ ์ด์ฉํด์ ๊ฐ๋ค์ ๊บผ๋ด๊ณ ๋ฃ๋ ๊ฒ์ด์ฃ .
๊ทธ๋ ๋ค๋ฉด ์ง๊ธ๋ถํฐ ๊ฐ์ฒด์ ๋ฌธ๋ฒ์ ๋ํด์ ์ดํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
var coworkers= {
"programmer": "egoing",
"designer": "leezche"
};
๊ฐ์ฒด๋ฅผ ๋ง๋ค ๋์๋ ๋ฐฐ์ด๊ณผ๋ ๋ฌ๋ฆฌ ์ค๊ดํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ฐ ์์๋ค์ ๊ฐ๊ฐ ์ด๋ฆ๊ณผ ๊ฐ์ผ๋ก ์ด๋ฃจ์ด์ ธ ์์ฃ . ์๋ฅผ ๋ค๋ฉด egoing์ด๋ผ๋ ๊ฐ์๋ programmer์ด๋ผ๋ ์ด๋ฆํ๊ฐ ๋ถ์ด์๋ ๊ฒ์ ๋๋ค.
๊ทธ๋ ๋ค๋ฉด ์ด ์์๋ค์ ๊บผ๋ผ ๋์๋ ์ด๋ป๊ฒ ํด์ผ ํ ๊น์? ๋ค์๊ณผ ๊ฐ์ด ์จ์ฃผ๋ฉด ๋ฉ๋๋ค.
document.write(coworkers.programmer)
document.write(coworkers["programmer"])
์ด๋ ๊ฒ ์ฐ๋ฉด coworkers๋ผ๋ ๊ฐ์ฒด ์์์ programmer์ด๋ผ๋ ์ด๋ฆ์ ๊ฐ์ง ๊ฐ์ ๊ฐ์ ธ์์ ์ถ๋ ฅํ๊ฒ ๋ฉ๋๋ค. ์ฒซ ๋ฒ์งธ ์ค๊ณผ ๋ ๋ฒ์งธ ์ค์ ์ฝ๋ ๋ชจ๋ ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๊ฒ ๋ฉ๋๋ค.
๋ค์์ผ๋ก๋ ๊ฐ์ฒด์ ์์๋ฅผ ์ถ๊ฐํด๋ด ์๋ค.
coworkers.bookkeeper = "duru";
coworkers["bookkeeper"] = "duru";
์ด๋ฐ ์ฝ๋๋ฅผ ์คํํ๊ฒ ๋๋ฉด coworkers๋ผ๋ ๊ฐ์ฒด ์์ bookkeeper์ด๋ผ๋ ์ด๋ฆ์ผ๋ก duru๋ผ๋ ๊ฐ์ ๋ฃ๋ ๊ฒ์ ๋๋ค. ๋ ์ค ๋ชจ๋ ๊ฐ์ ์์ ์ ์คํํ๊ฒ ๋ฉ๋๋ค. ํ์ง๋ง ๋ง์ฝ์ ์ด๋ฆ ์์ ๊ณต๋ฐฑ์ด ์๋ค๋ฉด ์ฒซ ๋ฒ์งธ ์ค์ ์ฝ๋์ฒ๋ผ ์ฐ๋ฉด ์ค๋ฅ๊ฐ ๋๊ธฐ ๋๋ฌธ์ ๋ ๋ฒ์งธ ์ค์ฒ๋ผ ์จ ์ฃผ์ด์ผ ํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ์๋์ ๊ฐ์ ์ฝ๋๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Object</h1>
<h2>Create</h2>
<script>
var coworkers = {
"programmer": "egoing",
"desiger": "leezche"
};
document.write("programmer : " + coworkers.programmer + "<br>");
document.write("designer : " + coworkers.desiger + "<br>");
coworkers.bookkeeper = "duru";
document.write("bookkeeper : " + coworkers.bookkeeper + "<br>");
coworkers["data scientist"] = "taeho";
document.write(" data scientist: " + coworkers["data scientist"] + "<br>");
</script>
</body>
</html>
์๊ฐํด๋ณด๊ธฐ
-
countries๋ผ๋ ์ด๋ฆ์ ๋น ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ณ , asia๋ผ๋ ์ด๋ฆ์ ๊ฐ์ง korea๋ผ๋ ๊ฐ๊ณผ, europe์ด๋ผ๋ ์ด๋ฆ์ ๊ฐ์ง england๋ผ๋ ๊ฐ์ ์ถ๊ฐํด๋ด ์๋ค.
var countries = {
"asia": "korea"
};
countries.europe = "england";
document.write("asia : " + countries.asia + "<br>");
document.write("europe : " + countries.europe + "<br>");
๋ค ํจ๊ป ๋ฐฐ์ฐ๊ณ ์ฑ์ฅํ๋ ๋ถ์คํธ์ฝ์ค
๋ถ์คํธ์ฝ์ค(boostcourse)๋ ๋ชจ๋ ํจ๊ป ๋ฐฐ์ฐ๊ณ ์ฑ์ฅํ๋ ๋น์๋ฆฌ SW ์จ๋ผ์ธ ํ๋ซํผ์ ๋๋ค.
www.boostcourse.org
hhhminme - Overview
๊พธ์คํ ๊ณต๋ถ์ค์ธ ์ด๋ณด ๊ฐ๋ฐ์์ง๋ง์ hub@kakao.com. hhhminme has 12 repositories available. Follow their code on GitHub.