자바 스크립트에서 Function.call()
은 this
값과 0 개 이상의 인수가 주어진 경우 Function
을 호출 할 수 있습니다.왜 내가 .call() 함수 호출을 할 수 없습니까?
Function.call
자체가 기능입니다. 따라서 이론적으로 Function.call
은 Function.call.call
과 같은 (또는 유사하게 작동하는) 함수 여야합니다. 내가 Function.call
에 .call()
를 호출 할 수 없습니다,
> Function.call()
[Function: anonymous]
그러나
> Function.call === Function.call.call
true
우리가 Function.call()
전화
,이 경우 것 같다. 여기
> Function.call.call()
TypeError: undefined is not a function
at repl:1:21
at REPLServer.defaultEval (repl.js:132:27)
at bound (domain.js:291:14)
at REPLServer.runBound [as eval] (domain.js:304:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
at REPLServer.Interface._line (readline.js:553:8)
at REPLServer.Interface._ttyWrite (readline.js:830:14)
at ReadStream.onkeypress (readline.js:109:10)
을 무슨 일이야? Function.call
은 분명히 기능입니다.이 오류 메시지에 나와있는 것처럼 undefined
이 아닙니다.
일반적인 프로그래밍 컨텍스트에서 무의미하지만 좋은 질문과 대답 :) – nicovank
@nicovank 물론, 나는 자바 스크립트의 "what if 's"를 탐색하고 있었고 실수로이 문제가 발생했습니다. :) – Qix
[물론 할 수있어] (http://stackoverflow.com/q/31074664/1048572)! – Bergi