728x90
반응형

분류 전체보기 140

26. closure

/** * Closure * A closure is the combination of a function and the lexical * environemnt within which that function was declared * "클로저는 어떤 함수와 해당 함수가 선언된 렉시컬 환경의 조합이다." * "상위 함수보다 하위 함수가 더 오래 살아있는 경우를 closure라고 한다." */function getNumber() { var number = 5; function innerGetNumber() { return number; } return innerGetNumber();}function getNumber() { var number = 5; funct..

코드팩토리 JS 2025.12.27

24. this

/** * this * * JS는 Lexical Scope를 사용하기때문에 함수의 상위 스코프가 * 정의 시점에 평가된다. * * *****하지만 this 키워드는 바인딩이 객체가 생성되는 시점에 결정된다. */const testFunction = function(){ return this;}console.log(testFunction()); // window Objectconst yuJin = { name: '안유진', year: 2003, sayHello: function(){ return `안녕하세요 저는 ${this.name}입니다.`; },}console.log(yuJin.sayHello()); ..

코드팩토리 JS 2025.12.27

20. property attribute

/** * Property Attribute * * 1) 데이터 프로퍼티 - 키와 값으로 형성된 실질적 값을 갖고있는 프로퍼티 * 2) 액세서 프로퍼티 - 자체적으로 값을 갖고 있지 않지만 다른 값을 가져오거나 * 설정할때 호출되는 함수로 구성된 프로퍼티 * 예를들면 getter와 setter */const yuJin = { name: '안유진', year: 2003,};console.log(Object.getOwnPropertyDescriptor(yuJin, 'year')); // {value: 2003, writable: true, enumerable: true, configurable: true}/** * 1) va..

코드팩토리 JS 2025.12.26
728x90
반응형