gpt4 book ai didi

javascript - 框架在javascript中是什么意思?

转载 作者:行者123 更新时间:2023-11-29 17:18:06 25 4
gpt4 key购买 nike

我正在阅读《可维护的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com