๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป๋ฐ”๋‹๋ผ JS๋กœ ํฌ๋กฌ ์•ฑ ๋งŒ๋“ค๊ธฐ : 2.4-2.7

change upยท2023๋…„ 5์›” 30์ผ
3
post-thumbnail
post-custom-banner

#2.4 Booleans

true :on/ false:off / null: ์˜๋„์ ์œผ๋กœ ๊ฐ’์„๋น„์›€ /undefined: ๊ฐ’์ด ์—†์Œ.
const amIfat = false;// ๊ฐ’์ด ์กด์žฌ
console.log(amIfat);
const amIslim = null;//๋ณ€์ˆ˜์— ๊ฐ’์ด ์กด์žฌ x,
console.log(amIfat);
let something;
console.log(something, amIfat);
//undefined,null

#2.5 Arrays

[]์‚ฌ์šฉํ•ด์„œ ๊ฐ๊ฐ์˜ ํ•ญ๋ชฉ์€, ๋กœ ๊ตฌ๋ถ„ํ•ด์ฃผ๋ฉฐ ๊ฐ’์˜ ์ˆœ์„œํ™”๋œ ๋ชฉ๋ก์œผ๋กœ ์ €์žฅํ•˜๊ณ 
์š”์†Œ์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ์ธ๋ฑ์Šค๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
//array์˜ ๋ชฉ์ ์€ ํ•˜๋‚˜์˜ variable์•ˆ์— ๋ฐ์ดํ„ฐ์˜ list๋ฅผ ๊ฐ€์ง€๋Š”๊ฒƒ์ด๋‹ค.
const mon = "mon";
const tue = "tue";
const wed = "wed";
const thu = "thu";

const daysOfweek = [mon, tue, wed, thu];
const nonsense = [1,2,"hello",3,4,5,undefined];
console.log(daysOfweek, nonsense);
const daysOfweeks = ["mon", "tue", "wed", "thu"];

console.log(daysOfweek[3]);//thu
//add one more day to the array
daysOfweek.push("sun"); // ๋ฐฐ์—ด์— ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€.
//get item from array
console.log(daysOfweek);

#2.6 Object

{}์‚ฌ์šฉํ•˜์—ฌ ์ •์˜๋˜๋ฉฐ ,key-value์˜ ์Œ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋‹ค. key๋ฅผ ํ†ตํ•ด ๊ฐ ์†์„ฑ์— ์ ‘๊ทผํ•˜๊ฑฐ๋‚˜
์†์„ฑ์„ ์ถ”๊ฐ€,์ˆ˜์ • ์‚ญ์ œ์— ์œ ์šฉํ•˜์—ฌ ๊ตฌ์กฐํ™”๋œ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ๊ธฐ๋ณธ์š”์†Œ.
const player = {
   name: "nico",
   points: 100,
   handsome: false,
};
console.log(player);
player.handsome = true;//constant์˜ ๊ฐ์ฒด๋ฅผ ์ˆ˜์ •ํ•˜๋Š”๊ฒƒ์€ ์•ˆ๋˜์ง€๋งŒ key์˜ value๋Š” ์ˆ˜์ •๊ฐ€๋Šฅ.
player.lastName="potato"; //์ƒˆ๋กœ์šด ํ”„๋กœํผํ‹ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š”๊ฒƒ๋„ ๊ฐ€๋Šฅ.
console.log(player.name);

#2.7 Functions

ํ•จ์ˆ˜๋Š” ์ฝ”๋“œ๋ฅผ ์บก์Šํ™”ํ•˜๊ณ  ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ธ”๋Ÿญ์œผ๋กœ ๋งŒ๋“œ๋Š”๊ฒƒ.
function sayhello() {
    console.log("hello");
}
sayhello(); //"hello"
profile
์ƒˆ์‹น์ด
post-custom-banner

1๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2023๋…„ 5์›” 30์ผ

์˜ค๋Š˜๋„ ์‹ค์Šต์„ ์„ฑ์‹คํ•˜๊ฒŒ ํ•˜์…จ๋„ค์š”~ ์ €๋„ ์ฝ”๋“œ๋ฅผ ์˜ฌ๋ฆฌ๊ณ ๋Š” ์‹ถ์€๋ฐ ์–ด๋–ป๊ฒŒ ์˜ฌ๋ฆฌ๋ฉด ์ข‹์„๊นŒ ๊ณ ๋ฏผ ์ค‘์ด์—์š”. TIL๋ธ”๋กœ๊ทธ ์œ ๋ช…ํ•œ ๋ฐ๋„ ํ•œ ๋ฒˆ์”ฉ ์ฐพ์•„๋ณด๊ณ ...๊พธ์ค€ํžˆ ๋ถ€๋‹ด์—†์ด ์ง€์†ํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹์€๋ฐ ๋ง์ด์ฃ ... ์•„๋ฌดํŠผ ์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค~!

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ