๐ŸŸจ 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