gpt4 book ai didi

ajax - 什么是变量[[FunctionLocation]],[[Scopes]] : in the Browser Console

转载 作者:行者123 更新时间:2023-12-04 04:00:05 24 4
gpt4 key购买 nike

使用 jQuery Ajax 时,在浏览器控制台中,我可以看到 xhr 对象有两个 props/字段,用一些奇怪的符号表示 [双方括号,在这种情况下不认为它表示数组];
首先,它们到底是什么,其次,我可以从我的 JavaScript 代码中访问这些值吗?

[[FunctionLocation]]: jquery-3.3.1.min.js:2
[[Scopes]]: Scopes[4]
0: Closure (w.Callbacks) {e: {…}, t: undefined, n: "", r: undefined, i: Array(0), …}
1: Closure {e: Window, r: document, i: ƒ, o: ƒ, a: ƒ, …}
2: Script {loc: Location, baseRestURL: "http://localhost:60123/MyVirtualDir"}
3: Global {parent: Window, opener: null, top: Window, length: 0, frames: Window, …}
enter image description here

最佳答案

不,您无法在代码中访问它们。
您在 Inspector 中看到的 [[FunctionLocation]] 属性已添加到调试器 C++ 代码的 V8Debugger::internalProperties() 中,该代码使用另一个 C++ 函数 V8Debugger::functionLocation() 来收集有关该函数的信息。 functionLocation() 然后使用许多 V8 特定的 C++ API,例如 v8::Function::GetScriptLineNumber() 和 GetScriptColumnNumber() 来找出确切的信息。
上述所有 API 仅可用于 C++ 代码,而不是 JavaScript 代码。如果您尝试在 Node.js 之类的平台上完成此任务,那么您应该能够编写一个原生模块。如果没有,那么你就不走运了。
还有一个类似的问题回答了here
[[Scopes]] 是 Chrome 开发者工具在 C++ 中添加和使用的私有(private)属性,here in the source .它显示函数范围内的变量,即可以从该函数访问哪些变量。

关于ajax - 什么是变量[[FunctionLocation]],[[Scopes]] : in the Browser Console,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63203261/

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