Modernizr 소스 코드에서이 발췌문을 찾았습니다. 이 call.call
를 사용할 필요가 왜 documentCreateElement.call(scopeDocument,nodeName)
하지 않는 것을 성취하는 무엇 단지 call
반대로 나는javascript에서 call.call이 수행하는 작업
var documentCreateElement = scopeDocument.createElement, documentCreateDocumentFragment = scopeDocument.createDocumentFragment;
// shiv the document
for (var i = 0, elements = html5.elements, l = elements.length; i < l; ++i) {
call.call(documentCreateElement, scopeDocument, elements[i]);
}
// shiv the document create element method
scopeDocument.createElement = function (nodeName) {
var element = call.call(documentCreateElement, scopeDocument, nodeName);
궁금? 사전에
덕분에
확실하게 이것은 '호출'이 무엇인가에 달려 있습니까? 'documentCreateElement.call (...)'은'documentCreateElement'를 호출합니다; 그러나'call.call'은'call'을 호출하므로'call.call (documentCreateElement, ...)''call'이'Function.prototype.call' 인 경우에만'documentCreateElement'를 호출합니다 - 이름에도 불구하고 그렇지 않습니다. – ruakh
(조금 덜 불투명하게하려면 : 코드가'CALL.call (documentCreateElement, ...)'라고 가정하십시오. 여전히'documentCreateElement.call (...) '과 동일하다고 생각하겠습니까? 변수'CALL'의 이름이'call'로 변경 되었기 때문에 함수 객체의'call' 메쏘드의 복사본이라는 의미는 아닙니다.) – ruakh
@ruakh [source code] (http://www.modernizr.com/downloads/modernizr-2.5.2.js). 'call' ->'Date.call' ->'Function.prototype.call'입니다. –