我正在阅读《可维护的 JavaScript》这本书。在书中,作者谈到了框架,需要帮助才能理解这意味着什么。
Passing arrays back and forth between frames was one of the original cross-frame issues in JavaScript. Developers quickly discovered that instanceof Array didn’t always produce appropriate results in these cases. As mentioned previously, each frame has its own Array constructor, so an instance from one frame isn’t recognized in another. Douglas Crockford first recommended performing some duck typing, testing for the presence of the sort() method:
// Duck typing arrays
function isArray(value) {
return typeof value.sort === "function";
}
最佳答案
这是指 HTML <frame>
element , 或 the modern <iframe>
重点是帧之间,Array
单独创建,你不能做 instanceof
在一个框架(可能是主文档)中创建的数组与在 <iframe>
中创建的数组之间的比较的代码。
关于javascript - 框架在javascript中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15227961/