๐ŸŸจ JavaScript/๊ฐœ๋…

    [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..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด์ง€ํ–ฅ (4) : ํด๋ž˜์Šค์˜ ์ƒ์† (sub classing)

    ํด๋ž˜์Šค์˜ ์ƒ์† (sub classing) class Goodcoder { constructor(age, lang, address) { this.age = age; this.lang = lang; this.address = address; } coding() { console.log(`๋‚ด๊ฐ€ ๊ณต๋ถ€์ค‘์ธ ์–ธ์–ด๋Š” ${this.lang}์ž…๋‹ˆ๋‹ค.`) } } ์ด ์•„๋ž˜์— ์ƒˆ๋กœ์šด ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ์€๋ฐ, class Goodcoder์˜ ๊ฐ’์„ ์ƒ์†์‹œํ‚ค๊ณ  ์‹ถ๋‹ค๋ฉด extends๋ฅผ ๋„ฃ์–ด ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. class Employee extends Goodcoder {} ์ด๋ ‡๊ฒŒ ์ƒˆ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด extends๋กœ ์ƒ์†์„ ํ•˜๋ฉด, ์ƒˆ๋กœ์šด ํด๋ž˜์Šค์— ์ด์ „ ํด๋ž˜์Šค ๊ฐ’๋“ค์ด ์ƒ์†๋œ๋‹ค. const noran = new Employee(20..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด์ง€ํ–ฅ (3) : ์ •์  ์†์„ฑ๊ณผ ๋ฉ”์†Œ๋“œ(static properties and methods)

    ์ •์  ์†์„ฑ๊ณผ ๋ฉ”์†Œ๋“œ(static properties and methods) static ํ‚ค์›Œ๋“œ๋ฅผ ๋ถ™์ด๋ฉด ํ”„๋กœํผํ‹ฐ๋‚˜ ๋ฉ”์†Œ๋“œ๊ฐ€ ์ธ์Šคํ„ด์Šคํ™”๋˜์ง€ ์•Š๊ณ  ํด๋ž˜์Šค ์ž์ฒด์— ๋ถ™๋Š”๋‹ค. class goodCoder { static codername = 'noran'; constructor(coderNumber) { this.coderNumber = coderNumber; } static printCoder() { console.log(goodCoder.codername); } } const coder1 = new goodCoder(1); const coder2 = new goodCoder(2); console.log(coder1.codername); //undefined ์œ„ ์ฝ”๋“œ์—์„œ console.log(coder1.cod..

    [mdn, ๋“œ๋ฆผ์ฝ”๋”ฉ ์™ธ] ๊ฐ์ฒด์ง€ํ–ฅ (2) : ๊ฐ์ฒด(object)์™€ getter and setter

    ๊ฐ์ฒด(object) https://sunshineyellow.tistory.com/17 [์ฝ”๋”ฉ์•™๋งˆ ์™ธ] ๊ฐ์ฒด(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 ์œ„ ๊ธ€์—์„œ ์ž ๊น ์งš๊ณ  ๋„˜์–ด๊ฐ„ ๊ฐ์ฒด๋ฅผ ํด๋ž˜์Šค์™€ ํ•จ๊ป˜ ์‹ฌํ™”ํ•™์Šตํ•œ๋‹ค. class Goodcoder { //constructor constructor(name, age) { this.name = ..