๐ŸŸจ JavaScript

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๋ฐฐ์—ด(array) (2) : ๋งจ๋’ค/๋งจ์•ž๋ถ€ํ„ฐ ์ถ”๊ฐ€,์‚ญ์ œ(push/pop,unshift/shift)

    ๋ฐฐ์—ด์„ ๋งŒ๋“ค์—ˆ๋‹ค. const goodcoders = ['noran', 'paran']; ์ถ”๊ฐ€ push : ๋งจ ๋’ค์— ์ถ”๊ฐ€ํ•˜๊ธฐ goodcoders.push('black','white'); unshift : ๋งจ ์•ž์—์„œ๋ถ€ํ„ฐ ์ถ”๊ฐ€ํ•˜๊ธฐ goodcoders.unshift('yellow','orange'); ์‚ญ์ œ pop : ๋งจ ๋’ค๋ฅผ ์‚ญ์ œํ•˜๊ธฐ goodcoders.pop(); shift : ๋งจ ์•ž์—์„œ๋ถ€ํ„ฐ ์‚ญ์ œํ•˜๊ธฐ goodcoders.shift('yellow','orange'); ์šฐ์„ ์ˆœ์œ„ shift์™€ unshift๋Š” pop๊ณผ push๋ณด๋‹ค ๋Š๋ฆฌ๋‹ค. (๋ฐ์ดํ„ฐ์˜ ๋งจ ๋’ค๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‚ญ์ œํ•˜๋Š” ๊ฒƒ์€ ์‰ฝ์ง€๋งŒ, ๋งจ ์•ž์„ ์ถ”๊ฐ€/์‚ญ์ œํ•˜๋Š” ๊ฒƒ์€ ํ•œ์นธ์”ฉ index๊ฐ€ ๋ฐ€๋ฆฌ๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ.) ์ถœ์ฒ˜ : ๋“œ๋ฆผ์ฝ”๋”ฉ https://www.youtube.c..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๋ฐฐ์—ด(array) : ๋ฐฐ์—ด์—์˜ ์ ‘๊ทผ๊ณผ looping

    object์™€ ์ž๋ฃŒ๊ตฌ์กฐ์˜ ์ฐจ์ด object๋Š” ์„œ๋กœ ์—ฐ๊ด€๋œ ํŠน์ง•์„ ๋ฌถ์–ด๋†“๋Š”๋‹ค. ์ž๋ฃŒ๊ตฌ์กฐ๋Š” ๋น„์Šทํ•œ ํƒ€์ž…์˜ object๋“ค์„ ๋ฌถ์–ด๋†“๋Š”๋‹ค. ๋ฐฐ์—ด(array) ๋ฐฐ์—ด์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ์นธ์นธ์œผ๋กœ ์งœ์—ฌ์ง„ index๋ฅผ ๊ฐ€์ง„ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ๋งํ•œ๋‹ค. ๋ฐฐ์—ด์˜ ์„ ์–ธ const coder1 = new Array(); const coder2 = [1,2]; index position (index์— ์ ‘๊ทผํ•˜๊ธฐ) ๋ฐฐ์—ด์„ ๋งŒ๋“ค์—ˆ๋‹ค. const goodcoders = ['noran', 'paran']; ์ด ๋ฐฐ์—ด์˜ ์ •๋ณด console.log(goodcoders); // 2) ['noran', 'paran'] //ํŽผ์น˜๋ฉด ์•„๋ž˜ ์ •๋ณด๊ฐ€ ๋‚˜์˜จ๋‹ค. //0: "noran" //1: "paran" //length: 2 //[[Prototype]]: Array..

    console.clear();

    ๊ฐœ๋ฐœ์ž๋ชจ๋“œ๋ฅผ ํ™œ์šฉํ•ด ๊ณต๋ถ€ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋ฉด ์ฝ˜์†”๋กœ๊ทธ๋ฅผ ์ „์ฒด์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. console.clear();

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด(Object)์™€ ํ”„๋กœํผํ‹ฐ(property) (3) : computed properties

    computed properties ์ ‘๊ทผ noran.name noran['name']; // computed properties ['name'] ํ˜•ํƒœ๋กœ ๋ฐ›์•„์˜ค๋Š” key๋Š” stringํƒ€์ž…์ด์–ด์•ผ ํ•œ๋‹ค. key ์ถ”๊ฐ€ noran['hasjob'] = true; ์–ด๋–จ๋•Œ computed properties๋ฅผ ์“ฐ๊ณ /์“ฐ์ง€ ์•Š์„๊นŒ? noran.name ํ˜•ํƒœ๋Š” ์ฝ”๋”ฉํ•˜๋Š” ์ˆœ๊ฐ„ ์‹ค์‹œ๊ฐ„์œผ๋กœ key์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์„ ๋ฐ›์•„์˜ค๊ณ  ์‹ถ์„ ๋•Œ ์“ด๋‹ค. noran['name'] ํ˜•ํƒœ๋Š” runtime์—์„œ ๊ฒฐ์ •๋˜๋Š” key (์–ด๋–ค key๋ฅผ ๋ฐ›์•„์˜ฌ์ง€ ๋ชจ๋ฅผ ๋•Œ)์ผ ๋•Œ ์“ด๋‹ค. computed properties๋ฅผ ์“ฐ๋Š” ์ƒํ™ฉ ์˜ˆ์‹œ function Goodcoder(obj, key) { console.log(obj.key); } printValue(nora..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด(Object)์™€ ํ”„๋กœํผํ‹ฐ(property) (2) : ์ƒ์„ฑ/์ˆ˜์ •๊ณผ cloning

    https://sunshineyellow.tistory.com/17?category=1037372 [์ฝ”๋”ฉ์•™๋งˆ ์™ธ] ๊ฐ์ฒด(Object)์™€ ํ”„๋กœํผํ‹ฐ(property) ๊ฐ์ฒด(Object) key์™€ value๋กœ ์ด๋ฃจ์–ด์งˆ ์ˆ˜ ์žˆ๋‹ค. 1. ํ•จ์ˆ˜ํ‘œํ˜„์‹ const goodCoder = function(name, age, coding) { name : 'Noran', age : 20, coding : function(){ console.log('ํ™”์ดํŒ…!'); } } name : 'Noran',.. sunshineyellow.tistory.com https://sunshineyellow.tistory.com/18?category=1037372 [์ฝ”๋”ฉ์•™๋งˆ ์™ธ] ๊ฐ์ฒด ๋ฆฌํ„ฐ๋Ÿด๊ณผ ๊ฐ์ฒด ์ ‘๊ทผ๋ฒ•, ๊ทธ๋ฆฌ๊ณ  ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋Š”..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด์ง€ํ–ฅ (5) : instanceOf ์—ฐ์‚ฐ์ž

    instanceOf ์—ฐ์‚ฐ์ž(operator) instanceOf ์—ฐ์‚ฐ์ž๋Š” ์ƒ์„ฑ์ž์˜ ํ”„๋กœํ† ํƒ€์ž… ์†์„ฑ์ด ๊ฐ์ฒด์˜ ํ”„๋กœํ† ํƒ€์ž… ์ฒด์ธ์— ์กด์žฌํ•˜๋Š”์ง€ ํŒ๋ณ„ํ•˜์—ฌ true ๋‚˜ false๋ฅผ ๋ฑ‰๋Š”๋‹ค. class Goodcoder { constructor(age, lang, address) { this.age = age; this.lang = lang; this.address = address; } } const noran = new Goodcoder(20,'Java','Seoul'); console.log(noran instanceof Goodcoder); //true console.log(paran instanceof Goodcoder); //Uncaught ReferenceError: paran is not defined..