๐จ JavaScript/๊ฐ๋
[mdn, ๋๋ฆผ์ฝ๋ฉ ์ธ] ๊ฐ์ฒด์งํฅ (5) : instanceOf ์ฐ์ฐ์
Zoeeey
2022. 5. 25. 14:07
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
์ถ์ฒ : ๋๋ฆผ์ฝ๋ฉ https://www.youtube.com/@dream-coding / MDN https://developer.mozilla.org/ko