๐จ 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 = ..