i'v 내 응용 프로그램에 오랫동안 자바 스크립트 게터를 사용하고, 항상 이런 식으로 작동하는지Javascript 게터는 어떻게 작동합니까?
을 생각하고 : 난 그냥 계산이 때마다 수행 발견
myobject.prototype.__defineGetter__('something', function() {
return DoSomeHeavyComputation() // this will be executed only once and will be saved
})
new myobject()
myobject.something // the computation will be done here
myobject.something // no computation will be done here.
...
리소스 또는 실제로 작동하는 방법을 보여주는 것이 있습니까?
이것은 단지 다른 기능을 가진 사람 일뿐입니다. 예를 들어 함수를 반환하는 함수를 실행하여 값을 캐싱 할 수 있습니다. –