javascrip
-
[Javascript] 프로퍼티 어트리뷰트, getOwnPropertyDescriptor,defineProperty,getDeepFrozen웹/JavaScript 2023. 1. 13. 09:07
I. 프로퍼티 어트리뷰트 property attributes 객체의 프로퍼티가 생성될 때 엔진에 의해 자동 정의되는 상태 💡 프로퍼티에는 두 종류가 있음 const person = { // ⭐️ 1. 데이터 프로퍼티들 fullName: '홍길동', ageInNumber: 25, // ⭐️ 2. 접근자 프로퍼티들 get name () { return this.fullName .split('') .map((letter, idx) => idx === 0 ? letter : '*') .join(''); }, get age () { return this.ageInNumber + '세'; }, set age (age) { this.ageInNumber = Number(age); } } console.lo..
-
[Javascript] 클래스, static ,field,constructor웹/JavaScript 2023. 1. 11. 12:17
I. 클래스 class를 사용하여 인스턴스 만들기 👉 MDN 문서 보기 class YalcoChicken { constructor (name, no) { this.name = name; this.no = no; } introduce () { // 💡 메서드 return `안녕하세요, ${this.no}호 ${this.name}점입니다!`; } } const chain1 = new YalcoChicken('판교', 3); const chain2 = new YalcoChicken('강남', 17); const chain3 = new YalcoChicken('제주', 24); console.log(chain1, chain1.introduce()); console.log(chain2, chain2.introdu..