animate(){
this.ctx.clearRect(0,0,this.width,this.height);
this.ctx.fillRect(this.x, this.y, 40, 40);
this.x += 1;
console.log(this)
requestAnimationFrame(this.animate())
}
이런 코드가 있는데 실행시키면 maximum call stack size exceeded 오류가 뜨는데 bind를 사용하면 오류 없는건 알겠는데 왜그런지를 모르겠음;;
bind가 무슨 용도인지도 아는데 왜그런 거임?
this.anim.bind()는 함수고 this.anim()은 함수 호출이니까 - dc App
함수호출은 그냥 계속 부르고 함수 실행?은 끝나면 다시 실행해서 오류가 안나는 건가????
아녀 걍 무한재귀에 빠져서 런타임에 터지는거 - dc App
requestAnimationFrame(this.animate.bind(this); 이렇게 해야지 된다 디스 바인딩이라고 검색해서 찾아보셈 - dc App
bind를 모르는것같은데?